diff --git a/Cargo.lock b/Cargo.lock index 81a5f8f..9d729db 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1586,12 +1586,6 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7c74b8349d32d297c9134b8c88677813a227df8f779daa29bfc29c183fe3dca6" -[[package]] -name = "convert_case" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" - [[package]] name = "core-foundation" version = "0.9.4" @@ -1814,19 +1808,6 @@ dependencies = [ "syn 2.0.101", ] -[[package]] -name = "derive_more" -version = "0.99.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6edb4b64a43d977b8e99788fe3a04d483834fba1215a7e02caa415b626497f7f" -dependencies = [ - "convert_case", - "proc-macro2", - "quote", - "rustc_version 0.4.1", - "syn 2.0.101", -] - [[package]] name = "derive_more" version = "1.0.0" @@ -2112,50 +2093,6 @@ dependencies = [ "windows-sys 0.59.0", ] -[[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 0.9.5", -] - -[[package]] -name = "ethbloom" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c22d4b5885b6aa2fe5e8b9329fb8d232bf739e434e6b87347c63bdd00c120f60" -dependencies = [ - "crunchy", - "fixed-hash", - "impl-rlp", - "impl-serde 0.4.0", - "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-rlp", - "impl-serde 0.4.0", - "primitive-types 0.12.2", - "uint 0.9.5", -] - [[package]] name = "expander" version = "2.2.1" @@ -2360,12 +2297,6 @@ version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988" -[[package]] -name = "futures-timer" -version = "3.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f288b0a4f20f9a56b5d1da57e2227c661b7b16168e2f72365f57b63326e29b24" - [[package]] name = "futures-util" version = "0.3.31" @@ -2828,16 +2759,6 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" -[[package]] -name = "idna" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d20d6b07bfbc108882d88ed8e37d39636dcc260e15e30c45e6ba089610b917c" -dependencies = [ - "unicode-bidi", - "unicode-normalization", -] - [[package]] name = "idna" version = "1.0.3" @@ -2888,24 +2809,6 @@ dependencies = [ "uint 0.10.0", ] -[[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-serde" version = "0.5.0" @@ -3046,21 +2949,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "jsonrpc-core" -version = "18.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14f7f76aef2d054868398427f6c54943cf3d1caa9a7ec7d0c38d69df97a965eb" -dependencies = [ - "futures", - "futures-executor", - "futures-util", - "log", - "serde", - "serde_derive", - "serde_json", -] - [[package]] name = "k256" version = "0.13.4" @@ -3704,8 +3592,6 @@ checksum = "0b34d9fd68ae0b74a41b21c03c2f62847aa0ffea044eee893b4c140b37e244e2" dependencies = [ "fixed-hash", "impl-codec 0.6.0", - "impl-rlp", - "impl-serde 0.4.0", "uint 0.9.5", ] @@ -3718,7 +3604,7 @@ dependencies = [ "fixed-hash", "impl-codec 0.7.1", "impl-num-traits", - "impl-serde 0.5.0", + "impl-serde", "scale-info", "uint 0.10.0", ] @@ -4102,7 +3988,6 @@ dependencies = [ "serde", "serde_json", "tracing", - "web3", ] [[package]] @@ -4796,7 +4681,7 @@ dependencies = [ "futures", "hash-db", "hash256-std-hasher", - "impl-serde 0.5.0", + "impl-serde", "itertools 0.11.0", "k256", "libsecp256k1", @@ -5009,7 +4894,7 @@ version = "22.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ee3b70ca340e41cde9d2e069d354508a6e37a6573d66f7cc38f11549002f64ec" dependencies = [ - "impl-serde 0.5.0", + "impl-serde", "parity-scale-codec", "ref-cast", "serde", @@ -5741,12 +5626,6 @@ version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eaea85b334db583fe3274d12b4cd1880032beab409c0d774be044d4480ab9a94" -[[package]] -name = "unicode-bidi" -version = "0.3.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c1cb5db39152898a79168971543b1cb5020dff7fe43c8dc468b0885f5e29df5" - [[package]] name = "unicode-ident" version = "1.0.18" @@ -5781,7 +5660,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32f8b686cadd1473f4bd0117a5d28d36b1ade384ea9b5069a1c40aefed7fda60" dependencies = [ "form_urlencoded", - "idna 1.0.3", + "idna", "percent-encoding", ] @@ -6021,30 +5900,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "web3" -version = "0.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5388522c899d1e1c96a4c307e3797e0f697ba7c77dd8e0e625ecba9dd0342937" -dependencies = [ - "arrayvec", - "derive_more 0.99.20", - "ethabi", - "ethereum-types", - "futures", - "futures-timer", - "hex", - "idna 0.4.0", - "jsonrpc-core", - "log", - "parking_lot", - "pin-project", - "rlp", - "serde", - "serde_json", - "tiny-keccak", -] - [[package]] name = "widestring" version = "1.2.0" diff --git a/Cargo.toml b/Cargo.toml index 67ed25f..a28e194 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -50,7 +50,6 @@ tracing-subscriber = { version = "0.3.19", default-features = false, features = "json", "env-filter", ] } -web3 = { version = "0.19.0", default-features = false } # revive compiler revive-solc-json-interface = { git = "https://github.com/paritytech/revive", rev = "3389865af7c3ff6f29a586d82157e8bc573c1a8e" } diff --git a/crates/format/Cargo.toml b/crates/format/Cargo.toml index 5742267..4352683 100644 --- a/crates/format/Cargo.toml +++ b/crates/format/Cargo.toml @@ -17,4 +17,3 @@ tracing = { workspace = true } semver = { workspace = true } serde = { workspace = true, features = ["derive"] } serde_json = { workspace = true } -web3 = { workspace = true } diff --git a/crates/format/src/input.rs b/crates/format/src/input.rs index af9547f..127640a 100644 --- a/crates/format/src/input.rs +++ b/crates/format/src/input.rs @@ -2,7 +2,7 @@ use std::{collections::HashMap, str::FromStr}; use alloy::{ json_abi::JsonAbi, - primitives::{Address, Bytes}, + primitives::{Address, Bytes, U256}, rpc::types::{TransactionInput, TransactionRequest}, }; use alloy_primitives::TxKind; @@ -136,21 +136,13 @@ impl Input { // // We're using indices in the following code in order to avoid the need for us to allocate // a new buffer for each one of the resolved arguments. - let mut calldata = vec![0u8; 4 + calldata_args.len() * 32]; - calldata[0..4].copy_from_slice(&function.selector().0); + let mut calldata = Vec::::with_capacity(4 + calldata_args.len() * 32); + calldata.extend(function.selector().0); for (arg_idx, arg) in calldata_args.iter().enumerate() { match resolve_argument(arg, deployed_contracts) { Ok(resolved) => { - // Compute where the resolved argument will go in the call-data. Again, we're - // doing this in order to avoid performing an extra allocation for an interim - // buffer that is then just used to extend the calldata vector. In here, the 4 - // is the size of the selector which we already wrote to the calldata and the 32 - // is the size of each `U256` we're writing to the calldata. - let start_inclusive = 4 + arg_idx * 32; - let end_exclusive = start_inclusive + 32; - let slot = &mut calldata[start_inclusive..end_exclusive]; - resolved.to_big_endian(slot); + calldata.extend(resolved.to_be_bytes::<32>()); } Err(error) => { tracing::error!(arg, arg_idx, ?error, "Failed to resolve argument"); @@ -208,33 +200,29 @@ fn default_caller() -> Address { /// This piece of code is taken from the matter-labs-tester repository which is licensed under MIT /// or Apache. The original source code can be found here: /// https://github.com/matter-labs/era-compiler-tester/blob/0ed598a27f6eceee7008deab3ff2311075a2ec69/compiler_tester/src/test/case/input/value.rs#L43-L146 -/// -/// [`U256`]: web3::types::U256 fn resolve_argument( value: &str, deployed_contracts: &HashMap, -) -> anyhow::Result { +) -> anyhow::Result { if let Some(instance) = value.strip_suffix(".address") { - Ok(web3::types::U256::from_big_endian( + Ok(U256::from_be_slice( deployed_contracts .get(instance) .ok_or_else(|| anyhow::anyhow!("Instance `{}` not found", instance))? .as_ref(), )) } else if let Some(value) = value.strip_prefix('-') { - let value = web3::types::U256::from_dec_str(value) + let value = U256::from_str_radix(value, 10) .map_err(|error| anyhow::anyhow!("Invalid decimal literal after `-`: {}", error))?; - if value > web3::types::U256::one() << 255u8 { + if value > U256::ONE << 255u8 { anyhow::bail!("Decimal literal after `-` is too big"); } let value = value - .checked_sub(web3::types::U256::one()) + .checked_sub(U256::ONE) .ok_or_else(|| anyhow::anyhow!("`-0` is invalid literal"))?; - Ok(web3::types::U256::max_value() - .checked_sub(value) - .expect("Always valid")) + Ok(U256::MAX.checked_sub(value).expect("Always valid")) } else if let Some(value) = value.strip_prefix("0x") { - Ok(web3::types::U256::from_str(value) + Ok(U256::from_str(value) .map_err(|error| anyhow::anyhow!("Invalid hexadecimal literal: {}", error))?) } else { // TODO: This is a set of "variables" that we need to be able to resolve to be fully in @@ -257,7 +245,7 @@ fn resolve_argument( tracing::error!(value, "Unsupported variable used"); anyhow::bail!("Encountered {value} which is currently unsupported by the framework"); } else { - Ok(web3::types::U256::from_dec_str(value) + Ok(U256::from_str_radix(value, 10) .map_err(|error| anyhow::anyhow!("Invalid decimal literal: {}", error))?) } }