From 0753dbd2f3c61e646424db52d0359dd8f1dd0eda Mon Sep 17 00:00:00 2001 From: Diana Carvalho Date: Tue, 10 Dec 2024 17:27:09 +0000 Subject: [PATCH] feat: Remove ethers from utils and Cargo.toml --- don't change below this line --- ENG-3850 <#DTT#> --- Cargo.lock | 245 ++++++--------------------------- Cargo.toml | 5 +- src/evm/protocol/safe_math.rs | 2 +- src/evm/protocol/vm/utils.rs | 80 +++++------ src/protocol/errors.rs | 6 - tycho_simulation_py/Cargo.toml | 1 - 6 files changed, 78 insertions(+), 261 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ef24f34c..f460b6d4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -17,7 +17,6 @@ name = "_tycho_simulation_py" version = "0.58.0" dependencies = [ "alloy", - "ethers", "num-bigint", "pyo3", "pyo3-log", @@ -327,7 +326,7 @@ dependencies = [ "ruint", "rustc-hash", "serde", - "sha3 0.10.8", + "sha3", "tiny-keccak", ] @@ -394,7 +393,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f542548a609dca89fcd72b3b9f355928cf844d4363c5eed9c5273a3dd225e097" dependencies = [ "alloy-rlp-derive", - "arrayvec 0.7.6", + "arrayvec", "bytes", ] @@ -942,12 +941,6 @@ dependencies = [ "rand", ] -[[package]] -name = "arrayvec" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" - [[package]] name = "arrayvec" version = "0.7.6" @@ -1350,16 +1343,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" @@ -1367,22 +1350,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" dependencies = [ "funty", - "radium 0.7.0", + "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 = [ - "block-padding", - "generic-array", -] - [[package]] name = "block-buffer" version = "0.10.4" @@ -1392,12 +1365,6 @@ dependencies = [ "generic-array", ] -[[package]] -name = "block-padding" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d696c370c750c948ada61c69a0ee2cbbb9c50b1019ddb86d9317157a99c2cae" - [[package]] name = "blst" version = "0.3.13" @@ -1442,12 +1409,6 @@ version = "3.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" -[[package]] -name = "byte-slice-cast" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0a5e3906bcbf133e33c1d4d95afc664ad37fbdb9f6568d8043e7ea8c27d93d3" - [[package]] name = "byte-slice-cast" version = "1.2.2" @@ -1716,7 +1677,7 @@ version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3db8fba409ce3dc04f7d804074039eb68b960b0829161f8e06c95fea3f122528" dependencies = [ - "bitvec 1.0.1", + "bitvec", "coins-bip32 0.8.7", "hmac", "once_cell", @@ -1732,7 +1693,7 @@ version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "74b169b26623ff17e9db37a539fe4f15342080df39f129ef7631df7683d6d9d4" dependencies = [ - "bitvec 1.0.1", + "bitvec", "coins-bip32 0.12.0", "hmac", "once_cell", @@ -1758,7 +1719,7 @@ dependencies = [ "serde", "serde_derive", "sha2", - "sha3 0.10.8", + "sha3", "thiserror 1.0.69", ] @@ -1777,7 +1738,7 @@ dependencies = [ "ripemd", "serde", "sha2", - "sha3 0.10.8", + "sha3", "thiserror 1.0.69", ] @@ -2246,7 +2207,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", @@ -2413,7 +2374,7 @@ dependencies = [ "rand", "rlp", "serde", - "sha3 0.10.8", + "sha3", "zeroize", ] @@ -2480,57 +2441,28 @@ dependencies = [ "serde", "serde_json", "sha2", - "sha3 0.10.8", + "sha3", "thiserror 1.0.69", "uuid 0.8.2", ] -[[package]] -name = "ethabi" -version = "13.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53d4e679d6864bc26210feb5cf044e245741cd9d7701b35c00440a6e84d61399" -dependencies = [ - "anyhow", - "ethereum-types 0.10.0", - "hex", - "serde", - "serde_json", - "sha3 0.9.1", - "thiserror 1.0.69", - "uint", -] - [[package]] name = "ethabi" version = "18.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7413c5f74cc903ea37386a8965a936cbeb334bd270862fdece542c1b2dcbc898" dependencies = [ - "ethereum-types 0.14.1", + "ethereum-types", "hex", "once_cell", "regex", "serde", "serde_json", - "sha3 0.10.8", + "sha3", "thiserror 1.0.69", "uint", ] -[[package]] -name = "ethbloom" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22a621dcebea74f2a6f2002d0a885c81ccf6cbdf86760183316a7722b5707ca4" -dependencies = [ - "crunchy", - "fixed-hash 0.7.0", - "impl-rlp", - "impl-serde 0.3.2", - "tiny-keccak", -] - [[package]] name = "ethbloom" version = "0.13.0" @@ -2538,40 +2470,26 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c22d4b5885b6aa2fe5e8b9329fb8d232bf739e434e6b87347c63bdd00c120f60" dependencies = [ "crunchy", - "fixed-hash 0.8.0", - "impl-codec 0.6.0", + "fixed-hash", + "impl-codec", "impl-rlp", - "impl-serde 0.4.0", + "impl-serde", "scale-info", "tiny-keccak", ] -[[package]] -name = "ethereum-types" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05dc5f0df4915fa6dff7f975a8366ecfaaa8959c74235469495153e7bb1b280e" -dependencies = [ - "ethbloom 0.10.0", - "fixed-hash 0.7.0", - "impl-rlp", - "impl-serde 0.3.2", - "primitive-types 0.8.0", - "uint", -] - [[package]] name = "ethereum-types" version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "02d215cbf040552efcbe99a38372fe80ab9d00268e20012b79fcd0f073edd8ee" dependencies = [ - "ethbloom 0.13.0", - "fixed-hash 0.8.0", - "impl-codec 0.6.0", + "ethbloom", + "fixed-hash", + "impl-codec", "impl-rlp", - "impl-serde 0.4.0", - "primitive-types 0.12.2", + "impl-serde", + "primitive-types", "scale-info", "uint", ] @@ -2669,13 +2587,13 @@ version = "2.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "82d80cc6ad30b14a48ab786523af33b37f28a8623fc06afd55324816ef18fb1f" dependencies = [ - "arrayvec 0.7.6", + "arrayvec", "bytes", "cargo_metadata 0.18.1", "chrono", "const-hex", "elliptic-curve", - "ethabi 18.0.0", + "ethabi", "generic-array", "k256", "num_enum", @@ -2847,7 +2765,7 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "139834ddba373bbdd213dffe02c8d110508dcf1726c2be27e8d1f7d7e1856418" dependencies = [ - "arrayvec 0.7.6", + "arrayvec", "auto_impl", "bytes", ] @@ -2876,18 +2794,6 @@ dependencies = [ "version_check", ] -[[package]] -name = "fixed-hash" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfcf0ed7fe52a17a03854ec54a9f76d6d84508d1c0e66bc1793301c73fc8493c" -dependencies = [ - "byteorder", - "rand", - "rustc-hex", - "static_assertions", -] - [[package]] name = "fixed-hash" version = "0.8.0" @@ -4226,22 +4132,13 @@ dependencies = [ "icu_properties", ] -[[package]] -name = "impl-codec" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1be51a921b067b0eaca2fad532d9400041561aa922221cc65f95a85641c6bf53" -dependencies = [ - "parity-scale-codec 1.3.7", -] - [[package]] name = "impl-codec" version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ba6a270039626615617f3f36d15fc827041df3b78c439da2cadfa47455a77f2f" dependencies = [ - "parity-scale-codec 3.6.12", + "parity-scale-codec", ] [[package]] @@ -4253,15 +4150,6 @@ dependencies = [ "rlp", ] -[[package]] -name = "impl-serde" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4551f042f3438e64dbd6226b20527fc84a6e1fe65688b58746a2f53623f25f5c" -dependencies = [ - "serde", -] - [[package]] name = "impl-serde" version = "0.4.0" @@ -4873,7 +4761,7 @@ version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a652d9771a63711fd3c3deb670acfbe5c30a4072e664d7a3bf5a9e1056ac72c3" dependencies = [ - "arrayvec 0.7.6", + "arrayvec", "itoa", ] @@ -4979,22 +4867,16 @@ version = "1.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" -[[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" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "786393f80485445794f6043fd3138854dd109cc6c4bd1a6383db304c9ce9b9ce" dependencies = [ - "arrayvec 0.7.6", + "arrayvec", "auto_impl", "bytes", - "ethereum-types 0.14.1", + "ethereum-types", "open-fastrlp-derive", ] @@ -5078,27 +4960,15 @@ dependencies = [ "sha2", ] -[[package]] -name = "parity-scale-codec" -version = "1.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4b26b16c7687c3075982af47719e481815df30bc544f7a6690763a25ca16e9d" -dependencies = [ - "arrayvec 0.5.2", - "bitvec 0.17.4", - "byte-slice-cast 0.3.5", - "serde", -] - [[package]] name = "parity-scale-codec" version = "3.6.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "306800abfa29c7f16596b5970a588435e3d5b3149683d00c12b699cc19f895ee" dependencies = [ - "arrayvec 0.7.6", - "bitvec 1.0.1", - "byte-slice-cast 1.2.2", + "arrayvec", + "bitvec", + "byte-slice-cast", "impl-trait-for-tuples", "parity-scale-codec-derive", "serde", @@ -5457,29 +5327,16 @@ dependencies = [ "elliptic-curve", ] -[[package]] -name = "primitive-types" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3824ae2c5e27160113b9e029a10ec9e3f0237bad8029f69c7724393c9fdefd8" -dependencies = [ - "fixed-hash 0.7.0", - "impl-codec 0.4.2", - "impl-rlp", - "impl-serde 0.3.2", - "uint", -] - [[package]] name = "primitive-types" version = "0.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b34d9fd68ae0b74a41b21c03c2f62847aa0ffea044eee893b4c140b37e244e2" dependencies = [ - "fixed-hash 0.8.0", - "impl-codec 0.6.0", + "fixed-hash", + "impl-codec", "impl-rlp", - "impl-serde 0.4.0", + "impl-serde", "scale-info", "uint", ] @@ -5762,12 +5619,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" @@ -6109,7 +5960,7 @@ dependencies = [ "alloy-primitives", "auto_impl", "bitflags 2.6.0", - "bitvec 1.0.1", + "bitvec", "c-kzg", "cfg-if", "dyn-clone", @@ -6253,8 +6104,8 @@ dependencies = [ "fastrlp", "num-bigint", "num-traits", - "parity-scale-codec 3.6.12", - "primitive-types 0.12.2", + "parity-scale-codec", + "primitive-types", "proptest", "rand", "rlp", @@ -6480,7 +6331,7 @@ checksum = "346a3b32eba2640d17a9cb5927056b08f3de90f65b72fe09402c2ad07d684d0b" dependencies = [ "cfg-if", "derive_more 1.0.0", - "parity-scale-codec 3.6.12", + "parity-scale-codec", "scale-info-derive", ] @@ -6749,18 +6600,6 @@ dependencies = [ "digest 0.10.7", ] -[[package]] -name = "sha3" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f81199417d4e5de3f04b1e871023acea7389672c4135918f05aa9cbf2f2fa809" -dependencies = [ - "block-buffer 0.9.0", - "digest 0.9.0", - "keccak", - "opaque-debug", -] - [[package]] name = "sha3" version = "0.10.8" @@ -7796,7 +7635,7 @@ dependencies = [ "chrono", "ethers", "mockall", - "primitive-types 0.12.2", + "primitive-types", "reqwest 0.11.27", "serde", "serde_json", @@ -7822,8 +7661,6 @@ dependencies = [ "clap", "crossterm", "dotenv", - "ethabi 13.0.0", - "ethers", "foundry-config", "foundry-evm", "futures 0.3.31", @@ -8272,10 +8109,10 @@ version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5388522c899d1e1c96a4c307e3797e0f697ba7c77dd8e0e625ecba9dd0342937" dependencies = [ - "arrayvec 0.7.6", + "arrayvec", "derive_more 0.99.18", - "ethabi 18.0.0", - "ethereum-types 0.14.1", + "ethabi", + "ethereum-types", "futures 0.3.31", "futures-timer", "hex", diff --git a/Cargo.toml b/Cargo.toml index 0bb188a6..dd02cf74 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -43,9 +43,6 @@ tycho-client = { git = "https://github.com/propeller-heads/tycho-indexer.git", p tycho-ethereum = { git = "https://github.com/propeller-heads/tycho-indexer.git", package = "tycho-ethereum", tag = "0.44.0" } # EVM dependencies -ethabi = { version = "13.0", optional = true } -# some core models still rely on ethers types instead of bytes, once this is addressed this will become optional. -ethers = { version = "2.0.13" } foundry-config = { git = "https://github.com/foundry-rs/foundry", rev = "57bb12e", optional = true } foundry-evm = { git = "https://github.com/foundry-rs/foundry", rev = "57bb12e", optional = true } alloy-primitives = { version = "0.8.9", features = [ @@ -80,7 +77,7 @@ unicode-width = "0.1.13" default = ["evm"] network_tests = [] evm = [ - "dep:ethabi", "dep:foundry-config", "dep:foundry-evm", "dep:revm", "dep:revm-inspectors" + "dep:foundry-config", "dep:foundry-evm", "dep:revm", "dep:revm-inspectors" ] [profile.bench] diff --git a/src/evm/protocol/safe_math.rs b/src/evm/protocol/safe_math.rs index 90e426be..c400a3e4 100644 --- a/src/evm/protocol/safe_math.rs +++ b/src/evm/protocol/safe_math.rs @@ -1,7 +1,7 @@ //! Safe Math //! //! This module contains basic functions to perform arithmetic operations on -//! numerical types of the ethers crate and preventing them from overflowing. +//! numerical types of the alloy crate and preventing them from overflowing. //! Should an operation cause an overflow a result containing TradeSimulationError //! will be returned. //! Functions for the types I256, U256, U512 are available. diff --git a/src/evm/protocol/vm/utils.rs b/src/evm/protocol/vm/utils.rs index 91be609c..06609b63 100644 --- a/src/evm/protocol/vm/utils.rs +++ b/src/evm/protocol/vm/utils.rs @@ -1,23 +1,24 @@ -use alloy_primitives::Address; -use num_bigint::BigInt; -use serde_json::Value; use std::{ collections::HashMap, env, fs::File, io::Read, path::{Path, PathBuf}, + str::FromStr, sync::{Arc, LazyLock}, }; -use ethabi::{self, decode, ParamType}; -use ethers::{ - prelude::ProviderError, - providers::{Http, Middleware, Provider}, - types::H160, +use alloy::{ + providers::{Provider, ProviderBuilder}, + transports::RpcError, }; +use alloy_primitives::{Address, U256}; +use alloy_sol_types::SolValue; + use hex::FromHex; use mini_moka::sync::Cache; +use num_bigint::BigInt; +use serde_json::Value; use revm::primitives::{Bytecode, Bytes}; use crate::{ @@ -105,38 +106,29 @@ fn parse_solidity_error_message(data: &str) -> String { // Check for specific error selectors: // Solidity Error(string) signature: 0x08c379a0 if data_bytes.starts_with(&[0x08, 0xc3, 0x79, 0xa0]) { - if let Ok(decoded) = decode(&[ParamType::String], &data_bytes[4..]) { - if let Some(ethabi::Token::String(error_string)) = decoded.first() { - return error_string.clone(); - } + if let Ok(decoded) = String::abi_decode(&data_bytes[4..], true) { + return decoded; } // Solidity Panic(uint256) signature: 0x4e487b71 } else if data_bytes.starts_with(&[0x4e, 0x48, 0x7b, 0x71]) { - if let Ok(decoded) = decode(&[ParamType::Uint(256)], &data_bytes[4..]) { - if let Some(ethabi::Token::Uint(error_code)) = decoded.first() { - let panic_codes = get_solidity_panic_codes(); - return panic_codes - .get(&error_code.as_u64()) - .cloned() - .unwrap_or_else(|| format!("Panic({})", error_code)); - } + if let Ok(decoded) = U256::abi_decode(&data_bytes[4..], true) { + let panic_codes = get_solidity_panic_codes(); + return panic_codes + .get(&decoded.as_limbs()[0]) + .cloned() + .unwrap_or_else(|| format!("Panic({})", decoded)); } } // Try decoding as a string (old Solidity revert case) - if let Ok(decoded) = decode(&[ParamType::String], &data_bytes) { - if let Some(ethabi::Token::String(error_string)) = decoded.first() { - return error_string.clone(); - } + if let Ok(decoded) = String::abi_decode(&data_bytes, true) { + return decoded; } - // Custom error, try to decode string again with offset - if let Ok(decoded) = decode(&[ParamType::String], &data_bytes[4..]) { - if let Some(ethabi::Token::String(error_string)) = decoded.first() { - return error_string.clone(); - } - } + // Custom error, try to decode string again with offset + if let Ok(decoded) = String::abi_decode(&data_bytes[4..], true) { + return decoded; } // Fallback if no decoding succeeded @@ -254,19 +246,15 @@ pub(crate) async fn get_code_for_contract( }; // Create a provider with the URL - let provider = - Provider::::try_from(connection_string).expect("could not instantiate HTTP Provider"); + let provider = ProviderBuilder::new() + .on_builtin(&connection_string) + .await + .unwrap(); - // Parse the address - let addr: H160 = address.parse().map_err(|_| { - SimulationError::FatalError(format!( - "Failed to get code for contract. Could not parse address: {}", - address - )) - })?; + let addr = Address::from_str(address).expect("Failed to parse address to get code for"); // Call eth_getCode to get the bytecode of the contract - match provider.get_code(addr, None).await { + match provider.get_code_at(addr).await { Ok(code) if code.is_empty() => { Err(SimulationError::FatalError("Empty code response from RPC".to_string())) } @@ -277,12 +265,13 @@ pub(crate) async fn get_code_for_contract( Err(e) => { println!("Error fetching code for address {}: {:?}", address, e); match e { - ProviderError::JsonRpcClientError(err) => Err(SimulationError::RecoverableError( - format!("Failed to get code for contract due to internal RPC error: {:?}", err), - )), + RpcError::Transport(err) => Err(SimulationError::RecoverableError(format!( + "Failed to get code for contract due to internal RPC error: {:?}", + err + ))), _ => Err(SimulationError::FatalError(format!( "Failed to get code for contract. Invalid response from RPC: {:?}", - e.to_string() + e ))), } } @@ -527,6 +516,7 @@ mod tests { use crate::utils::hexstring_to_vec; use dotenv::dotenv; + use hex::decode; use std::{fs::remove_file, io::Write}; use tempfile::NamedTempFile; @@ -692,7 +682,7 @@ mod tests { let bytecode: Bytecode = result.expect("Failed to retrieve ERC20 ABI result"); - let expected_bytes = revm::precompile::Bytes::from(ethers::utils::hex::decode("0x608060405234801561000f575f80fd5b50600436106100a6575f3560e01c8063395093511161006e578063395093511461011f57806370a082311461013257806395d89b411461015a578063a457c2d714610162578063a9059cbb14610175578063dd62ed3e14610188575f80fd5b806306fdde03146100aa578063095ea7b3146100c857806318160ddd146100eb57806323b872dd146100fd578063313ce56714610110575b5f80fd5b6100b261019b565b6040516100bf91906105b9565b60405180910390f35b6100db6100d636600461061f565b61022b565b60405190151581526020016100bf565b6002545b6040519081526020016100bf565b6100db61010b366004610647565b610244565b604051601281526020016100bf565b6100db61012d36600461061f565b610267565b6100ef610140366004610680565b6001600160a01b03165f9081526020819052604090205490565b6100b2610288565b6100db61017036600461061f565b610297565b6100db61018336600461061f565b6102f2565b6100ef6101963660046106a0565b6102ff565b6060600380546101aa906106d1565b80601f01602080910402602001604051908101604052809291908181526020018280546101d6906106d1565b80156102215780601f106101f857610100808354040283529160200191610221565b820191905f5260205f20905b81548152906001019060200180831161020457829003601f168201915b5050505050905090565b5f33610238818585610329565b60019150505b92915050565b5f336102518582856103dc565b61025c85858561043e565b506001949350505050565b5f3361023881858561027983836102ff565b6102839190610709565b610329565b6060600480546101aa906106d1565b5f33816102a482866102ff565b9050838110156102e557604051632983c0c360e21b81526001600160a01b038616600482015260248101829052604481018590526064015b60405180910390fd5b61025c8286868403610329565b5f3361023881858561043e565b6001600160a01b039182165f90815260016020908152604080832093909416825291909152205490565b6001600160a01b0383166103525760405163e602df0560e01b81525f60048201526024016102dc565b6001600160a01b03821661037b57604051634a1406b160e11b81525f60048201526024016102dc565b6001600160a01b038381165f8181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591015b60405180910390a3505050565b5f6103e784846102ff565b90505f198114610438578181101561042b57604051637dc7a0d960e11b81526001600160a01b038416600482015260248101829052604481018390526064016102dc565b6104388484848403610329565b50505050565b6001600160a01b03831661046757604051634b637e8f60e11b81525f60048201526024016102dc565b6001600160a01b0382166104905760405163ec442f0560e01b81525f60048201526024016102dc565b61049b8383836104a0565b505050565b6001600160a01b0383166104ca578060025f8282546104bf9190610709565b9091555061053a9050565b6001600160a01b0383165f908152602081905260409020548181101561051c5760405163391434e360e21b81526001600160a01b038516600482015260248101829052604481018390526064016102dc565b6001600160a01b0384165f9081526020819052604090209082900390555b6001600160a01b03821661055657600280548290039055610574565b6001600160a01b0382165f9081526020819052604090208054820190555b816001600160a01b0316836001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040516103cf91815260200190565b5f6020808352835180828501525f5b818110156105e4578581018301518582016040015282016105c8565b505f604082860101526040601f19601f8301168501019250505092915050565b80356001600160a01b038116811461061a575f80fd5b919050565b5f8060408385031215610630575f80fd5b61063983610604565b946020939093013593505050565b5f805f60608486031215610659575f80fd5b61066284610604565b925061067060208501610604565b9150604084013590509250925092565b5f60208284031215610690575f80fd5b61069982610604565b9392505050565b5f80604083850312156106b1575f80fd5b6106ba83610604565b91506106c860208401610604565b90509250929050565b600181811c908216806106e557607f821691505b60208210810361070357634e487b7160e01b5f52602260045260245ffd5b50919050565b8082018082111561023e57634e487b7160e01b5f52601160045260245ffdfea2646970667358221220dfc123d5852c9246ea16b645b377b4436e2f778438195cc6d6c435e8c73a20e764736f6c634300081403000000000000000000000000000000000000000000000000000000000000000000").unwrap()); + let expected_bytes = revm::precompile::Bytes::from(decode("608060405234801561000f575f80fd5b50600436106100a6575f3560e01c8063395093511161006e578063395093511461011f57806370a082311461013257806395d89b411461015a578063a457c2d714610162578063a9059cbb14610175578063dd62ed3e14610188575f80fd5b806306fdde03146100aa578063095ea7b3146100c857806318160ddd146100eb57806323b872dd146100fd578063313ce56714610110575b5f80fd5b6100b261019b565b6040516100bf91906105b9565b60405180910390f35b6100db6100d636600461061f565b61022b565b60405190151581526020016100bf565b6002545b6040519081526020016100bf565b6100db61010b366004610647565b610244565b604051601281526020016100bf565b6100db61012d36600461061f565b610267565b6100ef610140366004610680565b6001600160a01b03165f9081526020819052604090205490565b6100b2610288565b6100db61017036600461061f565b610297565b6100db61018336600461061f565b6102f2565b6100ef6101963660046106a0565b6102ff565b6060600380546101aa906106d1565b80601f01602080910402602001604051908101604052809291908181526020018280546101d6906106d1565b80156102215780601f106101f857610100808354040283529160200191610221565b820191905f5260205f20905b81548152906001019060200180831161020457829003601f168201915b5050505050905090565b5f33610238818585610329565b60019150505b92915050565b5f336102518582856103dc565b61025c85858561043e565b506001949350505050565b5f3361023881858561027983836102ff565b6102839190610709565b610329565b6060600480546101aa906106d1565b5f33816102a482866102ff565b9050838110156102e557604051632983c0c360e21b81526001600160a01b038616600482015260248101829052604481018590526064015b60405180910390fd5b61025c8286868403610329565b5f3361023881858561043e565b6001600160a01b039182165f90815260016020908152604080832093909416825291909152205490565b6001600160a01b0383166103525760405163e602df0560e01b81525f60048201526024016102dc565b6001600160a01b03821661037b57604051634a1406b160e11b81525f60048201526024016102dc565b6001600160a01b038381165f8181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591015b60405180910390a3505050565b5f6103e784846102ff565b90505f198114610438578181101561042b57604051637dc7a0d960e11b81526001600160a01b038416600482015260248101829052604481018390526064016102dc565b6104388484848403610329565b50505050565b6001600160a01b03831661046757604051634b637e8f60e11b81525f60048201526024016102dc565b6001600160a01b0382166104905760405163ec442f0560e01b81525f60048201526024016102dc565b61049b8383836104a0565b505050565b6001600160a01b0383166104ca578060025f8282546104bf9190610709565b9091555061053a9050565b6001600160a01b0383165f908152602081905260409020548181101561051c5760405163391434e360e21b81526001600160a01b038516600482015260248101829052604481018390526064016102dc565b6001600160a01b0384165f9081526020819052604090209082900390555b6001600160a01b03821661055657600280548290039055610574565b6001600160a01b0382165f9081526020819052604090208054820190555b816001600160a01b0316836001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040516103cf91815260200190565b5f6020808352835180828501525f5b818110156105e4578581018301518582016040015282016105c8565b505f604082860101526040601f19601f8301168501019250505092915050565b80356001600160a01b038116811461061a575f80fd5b919050565b5f8060408385031215610630575f80fd5b61063983610604565b946020939093013593505050565b5f805f60608486031215610659575f80fd5b61066284610604565b925061067060208501610604565b9150604084013590509250925092565b5f60208284031215610690575f80fd5b61069982610604565b9392505050565b5f80604083850312156106b1575f80fd5b6106ba83610604565b91506106c860208401610604565b90509250929050565b600181811c908216806106e557607f821691505b60208210810361070357634e487b7160e01b5f52602260045260245ffd5b50919050565b8082018082111561023e57634e487b7160e01b5f52601160045260245ffdfea2646970667358221220dfc123d5852c9246ea16b645b377b4436e2f778438195cc6d6c435e8c73a20e764736f6c634300081403000000000000000000000000000000000000000000000000000000000000000000").unwrap()); let expected_bytecode = Bytecode::new_raw(expected_bytes); assert_eq!(bytecode, expected_bytecode); } diff --git a/src/protocol/errors.rs b/src/protocol/errors.rs index 823ac7a4..f413264a 100644 --- a/src/protocol/errors.rs +++ b/src/protocol/errors.rs @@ -97,9 +97,3 @@ impl From for FileError { FileError::Parse(err) } } - -impl From for SimulationError { - fn from(err: ethers::abi::Error) -> Self { - SimulationError::FatalError(err.to_string()) - } -} diff --git a/tycho_simulation_py/Cargo.toml b/tycho_simulation_py/Cargo.toml index 0aa85637..91dbf99b 100644 --- a/tycho_simulation_py/Cargo.toml +++ b/tycho_simulation_py/Cargo.toml @@ -13,7 +13,6 @@ num-bigint = "0.4.3" pyo3 = { version = "0.19", features = ["num-bigint", "extension-module"] } tycho-simulation = { path = "../" } tokio = { version = "1.38.0", features = ["full"] } -ethers = "2.0.13" alloy = { version = "0.5.4", features = ["providers"] } revm = { version = "17.1.0", features = [ "ethersdb",