diff --git a/Cargo.lock b/Cargo.lock index 26cdab3bb..ec194355f 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 304597c16..636f4fd62 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 ec0884aa2..bd9325191 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 8deafcd5d..a8b7f56c0 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 33c497562..c8763d08c 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())?;