diff --git a/Cargo.lock b/Cargo.lock index 9108e9514c..e4d50d7d64 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" @@ -65,7 +65,6 @@ name = "alerter" version = "0.1.0" dependencies = [ "anyhow", - "chrono", "clap", "humantime", "mimalloc", @@ -80,7 +79,6 @@ dependencies = [ "shared", "tokio", "tracing", - "tracing-subscriber", "url", "warp", ] @@ -276,12 +274,10 @@ dependencies = [ "contracts", "cow-amm", "database", - "derivative", - "derive_more", + "derive_more 1.0.0", "ethcontract", "ethrpc", "futures", - "gas-estimation", "hex", "hex-literal", "humantime", @@ -307,7 +303,6 @@ dependencies = [ "shared", "sqlx", "strum", - "testlib", "thiserror", "tokio", "tracing", @@ -1271,7 +1266,7 @@ checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" name = "chain" version = "0.1.0" dependencies = [ - "derive_more", + "derive_more 1.0.0", "ethcontract", "serde", "serde_json", @@ -1420,6 +1415,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 = "cookie" version = "0.17.0" @@ -1477,7 +1481,6 @@ dependencies = [ "hex", "hex-literal", "model", - "primitive-types", "shared", "tokio", "tracing", @@ -1679,7 +1682,6 @@ dependencies = [ "const_format", "futures", "hex", - "hex-literal", "maplit", "sqlx", "strum", @@ -1724,13 +1726,35 @@ version = "0.99.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" dependencies = [ - "convert_case", + "convert_case 0.4.0", "proc-macro2", "quote", "rustc_version", "syn 1.0.109", ] +[[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 = [ + "convert_case 0.6.0", + "proc-macro2", + "quote", + "syn 2.0.66", + "unicode-xid", +] + [[package]] name = "difflib" version = "0.4.0" @@ -1776,8 +1800,7 @@ dependencies = [ "clap", "contracts", "cow-amm", - "derivative", - "derive_more", + "derive_more 1.0.0", "ethabi", "ethcontract", "ethereum-types", @@ -1831,13 +1854,11 @@ version = "1.0.0" dependencies = [ "anyhow", "app-data", - "async-trait", "autopilot", "axum", "chrono", "clap", "contracts", - "cow-amm", "database", "driver", "ethcontract", @@ -1849,7 +1870,6 @@ dependencies = [ "number", "observe", "orderbook", - "rand", "refunder", "reqwest", "secp256k1", @@ -1862,10 +1882,7 @@ dependencies = [ "sqlx", "tempfile", "tokio", - "tower", - "tower-http", "tracing", - "uuid", "warp", "web3", ] @@ -2053,7 +2070,6 @@ dependencies = [ "async-trait", "contracts", "ethcontract", - "ethereum-types", "futures", "hex", "hex-literal", @@ -3096,7 +3112,7 @@ dependencies = [ "bigdecimal", "bytes-hex", "chrono", - "derivative", + "derive_more 1.0.0", "hex", "hex-literal", "lazy_static", @@ -3108,7 +3124,6 @@ dependencies = [ "serde", "serde_json", "serde_with", - "shared", "strum", "testlib", "web3", @@ -3378,7 +3393,6 @@ dependencies = [ name = "order-validation" version = "0.1.0" dependencies = [ - "cached", "contracts", "ethcontract", "thiserror", @@ -3402,12 +3416,10 @@ dependencies = [ "database", "ethcontract", "futures", - "gas-estimation", "hex", "hex-literal", "humantime", "hyper", - "maplit", "mimalloc", "mockall 0.12.1", "model", @@ -3420,21 +3432,18 @@ dependencies = [ "prometheus", "prometheus-metric-storage", "reqwest", - "secp256k1", "serde", "serde_json", "serde_with", "shared", "sqlx", "strum_macros", - "testlib", "thiserror", "tokio", "tracing", "url", "vergen", "warp", - "web3", ] [[package]] @@ -3884,7 +3893,6 @@ version = "0.1.0" dependencies = [ "anyhow", "async-trait", - "chrono", "clap", "contracts", "database", @@ -3893,19 +3901,15 @@ dependencies = [ "futures", "gas-estimation", "humantime", - "lazy_static", "mimalloc", - "model", "number", "observe", - "primitive-types", "prometheus", "prometheus-metric-storage", "shared", "sqlx", "tokio", "tracing", - "tracing-subscriber", "url", ] @@ -4467,10 +4471,10 @@ dependencies = [ "dashmap", "database", "derivative", + "derive_more 1.0.0", "ethcontract", "ethcontract-mock", "ethrpc", - "flate2", "futures", "gas-estimation", "hex", @@ -4499,17 +4503,13 @@ dependencies = [ "serde_json", "serde_with", "strum", - "tempfile", "testlib", "thiserror", - "time", "tokio", - "tokio-stream", "tracing", "tracing-subscriber", "ttl_cache", "url", - "warp", "web3", ] @@ -4570,21 +4570,14 @@ dependencies = [ "anyhow", "arc-swap", "async-trait", - "chrono", - "clap", "contracts", "derivative", "ethcontract", - "ethcontract-mock", "ethrpc", - "flate2", "futures", - "gas-estimation", "hex", "hex-literal", - "humantime", "itertools 0.12.1", - "jsonrpc-core", "lazy_static", "maplit", "mockall 0.12.1", @@ -4596,20 +4589,13 @@ dependencies = [ "primitive-types", "prometheus", "prometheus-metric-storage", - "rand", - "rate-limit", - "reqwest", "serde", "serde_json", - "serde_with", "shared", "strum", "testlib", - "thiserror", "tokio", "tracing", - "tracing-subscriber", - "url", "web3", ] @@ -4624,11 +4610,10 @@ dependencies = [ "chrono", "clap", "contracts", - "derive_more", + "derive_more 1.0.0", "ethcontract", "ethereum-types", "ethrpc", - "futures", "hex", "hex-literal", "hyper", @@ -4639,9 +4624,7 @@ dependencies = [ "observe", "prometheus", "prometheus-metric-storage", - "rate-limit", "reqwest", - "s3", "serde", "serde_json", "serde_with", @@ -4649,7 +4632,6 @@ dependencies = [ "solver", "solvers-dto", "tempfile", - "thiserror", "tokio", "toml", "tower", @@ -5557,9 +5539,6 @@ name = "uuid" version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a183cf7feeba97b4dd1c0d46788634f6221d87fa961b305bed08c851829efcc0" -dependencies = [ - "getrandom", -] [[package]] name = "valuable" @@ -5729,7 +5708,7 @@ dependencies = [ "arrayvec", "base64 0.21.7", "bytes", - "derive_more", + "derive_more 0.99.17", "ethabi", "ethereum-types", "futures", diff --git a/Cargo.toml b/Cargo.toml index c3dd3d5a69..d25c30318f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,7 @@ cached = { version = "0.49.3", default-features = false } chrono = { version = "0.4.38", default-features = false } clap = { version = "4.5.6", features = ["derive", "env"] } derivative = "2.2.0" -derive_more = "0.99.17" +derive_more = { version = "1.0.0", features = ["full"] } ethcontract = { version = "0.25.7", default-features = false, features = ["aws-kms"] } mimalloc = "0.1.43" ethcontract-generate = { version = "0.25.7", default-features = false } diff --git a/crates/alerter/Cargo.toml b/crates/alerter/Cargo.toml index 6b836c495c..168768e0b7 100644 --- a/crates/alerter/Cargo.toml +++ b/crates/alerter/Cargo.toml @@ -7,7 +7,6 @@ license = "MIT OR Apache-2.0" [dependencies] anyhow = { workspace = true } -chrono = { workspace = true } clap = { workspace = true } humantime = { workspace = true } observe = { path = "../observe" } @@ -22,7 +21,6 @@ serde = { workspace = true } shared = { path = "../shared" } tokio = { workspace = true, features = ["macros", "time", "rt-multi-thread"] } tracing = { workspace = true } -tracing-subscriber = { workspace = true } url = { workspace = true } warp = { workspace = true } diff --git a/crates/autopilot/Cargo.toml b/crates/autopilot/Cargo.toml index 8a28b46688..9cdfb90295 100644 --- a/crates/autopilot/Cargo.toml +++ b/crates/autopilot/Cargo.toml @@ -26,12 +26,10 @@ clap = { workspace = true } contracts = { path = "../contracts" } cow-amm = { path = "../cow-amm" } database = { path = "../database" } -derivative = { workspace = true } derive_more = { workspace = true } ethcontract = { workspace = true } ethrpc = { path = "../ethrpc" } futures = { workspace = true } -gas-estimation = { workspace = true } observe = { path = "../observe" } hex = { workspace = true } hex-literal = { workspace = true } @@ -64,7 +62,6 @@ web3 = { workspace = true } [dev-dependencies] mockall = { workspace = true } -testlib = { path = "../testlib" } tokio = { workspace = true, features = ["test-util"] } [lints] diff --git a/crates/autopilot/src/database/competition.rs b/crates/autopilot/src/database/competition.rs index 7d55fce9c1..81cc5e63ef 100644 --- a/crates/autopilot/src/database/competition.rs +++ b/crates/autopilot/src/database/competition.rs @@ -9,15 +9,14 @@ use { surplus_capturing_jit_order_owners, Address, }, - derivative::Derivative, + derive_more::Debug, model::solver_competition::SolverCompetitionDB, number::conversions::u256_to_big_decimal, primitive_types::{H160, U256}, std::collections::{BTreeMap, HashSet}, }; -#[derive(Clone, Default, Derivative)] -#[derivative(Debug)] +#[derive(Clone, Default, Debug)] pub struct Competition { pub auction_id: AuctionId, pub winner: H160, diff --git a/crates/cow-amm/Cargo.toml b/crates/cow-amm/Cargo.toml index e4a949b6b5..7c3bcc4dae 100644 --- a/crates/cow-amm/Cargo.toml +++ b/crates/cow-amm/Cargo.toml @@ -11,7 +11,6 @@ contracts = { path = "../contracts" } ethcontract = { workspace = true } ethrpc = { path = "../ethrpc" } model = { path = "../model" } -primitive-types = { workspace = true } shared = { path = "../shared" } tokio = { workspace = true, features = [] } tracing = { workspace = true } diff --git a/crates/database/Cargo.toml b/crates/database/Cargo.toml index 59d00f0745..572530a842 100644 --- a/crates/database/Cargo.toml +++ b/crates/database/Cargo.toml @@ -15,7 +15,6 @@ sqlx = { workspace = true } strum = { workspace = true } [dev-dependencies] -hex-literal = { workspace = true } maplit = { workspace = true } tokio = { workspace = true, features = ["macros"] } diff --git a/crates/driver/Cargo.toml b/crates/driver/Cargo.toml index 874cc5a008..35dd748162 100644 --- a/crates/driver/Cargo.toml +++ b/crates/driver/Cargo.toml @@ -24,7 +24,6 @@ axum = { workspace = true } bigdecimal = { workspace = true } chrono = { workspace = true, features = ["clock"], default-features = false } cow-amm = { path = "../cow-amm" } -derivative = { workspace = true } derive_more = { workspace = true } ethabi = "18.0" ethereum-types = { workspace = true } diff --git a/crates/driver/src/domain/liquidity/uniswap/v3.rs b/crates/driver/src/domain/liquidity/uniswap/v3.rs index 7293c1a1e0..8325db95a5 100644 --- a/crates/driver/src/domain/liquidity/uniswap/v3.rs +++ b/crates/driver/src/domain/liquidity/uniswap/v3.rs @@ -6,15 +6,14 @@ use { liquidity::{self, InvalidSwap}, }, }, - derivative::Derivative, + derive_more::Debug, std::collections::BTreeMap, }; /// A Uniswap V3 concentrated liquidity pool. /// /// [^1]: -#[derive(Clone, Derivative)] -#[derivative(Debug)] +#[derive(Clone, Debug)] pub struct Pool { pub router: eth::ContractAddress, pub address: eth::ContractAddress, @@ -22,7 +21,7 @@ pub struct Pool { pub sqrt_price: SqrtPrice, pub liquidity: Liquidity, pub tick: Tick, - #[derivative(Debug = "ignore")] + #[debug(ignore)] pub liquidity_net: BTreeMap, pub fee: Fee, } diff --git a/crates/driver/src/infra/liquidity/config.rs b/crates/driver/src/infra/liquidity/config.rs index 49fd218ac9..9900d374a3 100644 --- a/crates/driver/src/infra/liquidity/config.rs +++ b/crates/driver/src/infra/liquidity/config.rs @@ -1,6 +1,6 @@ use { crate::{domain::eth, infra::blockchain::contracts::deployment_address}, - derivative::Derivative, + derive_more::Debug, hex_literal::hex, reqwest::Url, std::{collections::HashSet, time::Duration}, @@ -235,11 +235,10 @@ impl BalancerV2 { } /// ZeroEx liquidity fetching options. -#[derive(Clone, Derivative)] -#[derivative(Debug)] +#[derive(Clone, Debug)] pub struct ZeroEx { pub base_url: String, - #[derivative(Debug = "ignore")] + #[debug(ignore)] pub api_key: Option, pub http_timeout: Duration, } diff --git a/crates/e2e/Cargo.toml b/crates/e2e/Cargo.toml index 2540329abc..96a90421ca 100644 --- a/crates/e2e/Cargo.toml +++ b/crates/e2e/Cargo.toml @@ -8,13 +8,11 @@ license = "MIT OR Apache-2.0" [dependencies] app-data = { path = "../app-data" } anyhow = { workspace = true } -async-trait = { workspace = true } autopilot = { path = "../autopilot" } axum = { workspace = true } chrono = { workspace = true } clap = { workspace = true } contracts = { path = "../contracts" } -cow-amm = { path = "../cow-amm" } database = { path = "../database" } driver = { path = "../driver" } ethcontract = { workspace = true } @@ -36,16 +34,12 @@ solvers-dto = { path = "../solvers-dto" } sqlx = { workspace = true } tempfile = { workspace = true } tokio = { workspace = true, features = ["macros", "process"] } -tower = "0.4" -tower-http = { version = "0.4", features = ["limit", "trace"] } tracing = { workspace = true } warp = { workspace = true } web3 = { workspace = true, features = ["http"] } -uuid = { version = "1.8.0", features = ["v4"] } [dev-dependencies] futures = { workspace = true } -rand = { workspace = true } refunder = { path = "../refunder" } [lints] diff --git a/crates/ethrpc/Cargo.toml b/crates/ethrpc/Cargo.toml index 1d26464d9b..a6e628dabc 100644 --- a/crates/ethrpc/Cargo.toml +++ b/crates/ethrpc/Cargo.toml @@ -13,7 +13,6 @@ doctest = false [dependencies] anyhow = { workspace = true } async-trait = { workspace = true } -ethereum-types = { workspace = true } futures = { workspace = true } hex = { workspace = true } hex-literal = { workspace = true } diff --git a/crates/model/Cargo.toml b/crates/model/Cargo.toml index 4636d07a9f..d6a8f19af1 100644 --- a/crates/model/Cargo.toml +++ b/crates/model/Cargo.toml @@ -14,7 +14,7 @@ app-data = { path = "../app-data" } bytes-hex = { path = "../bytes-hex" } bigdecimal = { workspace = true } chrono = { workspace = true, features = ["serde", "clock"] } -derivative = { workspace = true } +derive_more = { workspace = true } hex = { workspace = true, default-features = false } hex-literal = { workspace = true } lazy_static = { workspace = true } @@ -29,7 +29,6 @@ web3 = { workspace = true, features = ["signing"] } [dev-dependencies] serde_json = { workspace = true } -shared = { path = "../shared" } maplit = { workspace = true } testlib = { path = "../testlib" } diff --git a/crates/model/src/order.rs b/crates/model/src/order.rs index 0e2f6c86a4..4d3ca859a7 100644 --- a/crates/model/src/order.rs +++ b/crates/model/src/order.rs @@ -1,6 +1,5 @@ //! Contains the order type as described by the specification with serialization //! as described by the openapi documentation. -#![allow(clippy::needless_lifetimes)] // todo: migrate from derivative to derive_more use { crate::{ @@ -13,7 +12,7 @@ use { anyhow::{anyhow, Result}, app_data::{hash_full_app_data, AppDataHash}, chrono::{offset::Utc, DateTime}, - derivative::Derivative, + derive_more::Debug as DeriveDebug, hex_literal::hex, num::BigUint, number::serialization::HexOrDecimalU256, @@ -642,7 +641,7 @@ impl ::serde::Serialize for EthflowData { } } -#[derive(Debug, Eq, PartialEq, Clone, Derivative, Deserialize, Serialize)] +#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub enum OnchainOrderPlacementError { ValidToTooFarInTheFuture, @@ -669,8 +668,7 @@ pub enum OnchainOrderPlacementError { // stores all data related to onchain order palcement #[serde_as] -#[derive(Eq, PartialEq, Clone, Default, Derivative, Deserialize, Serialize)] -#[derivative(Debug)] +#[derive(Eq, PartialEq, Clone, Default, Deserialize, Serialize, Debug)] #[serde(rename_all = "camelCase")] pub struct OnchainOrderData { pub sender: H160, @@ -679,8 +677,7 @@ pub struct OnchainOrderData { /// An order as provided to the orderbook by the frontend. #[serde_as] -#[derive(Eq, PartialEq, Clone, Default, Derivative, Deserialize, Serialize)] -#[derivative(Debug)] +#[derive(Eq, PartialEq, Clone, Default, Deserialize, Serialize, DeriveDebug)] #[serde(rename_all = "camelCase")] pub struct OrderMetadata { pub creation_date: DateTime, @@ -689,10 +686,10 @@ pub struct OrderMetadata { /// deprecated, always set to null #[serde_as(as = "Option")] pub available_balance: Option, - #[derivative(Debug(format_with = "debug_biguint_to_string"))] + #[debug("{}", format_args!("{executed_buy_amount}"))] #[serde_as(as = "DisplayFromStr")] pub executed_buy_amount: BigUint, - #[derivative(Debug(format_with = "debug_biguint_to_string"))] + #[debug("{}", format_args!("{executed_sell_amount}"))] #[serde_as(as = "DisplayFromStr")] pub executed_sell_amount: BigUint, #[serde_as(as = "HexOrDecimalU256")] @@ -1010,13 +1007,6 @@ impl BuyTokenDestination { } } -pub fn debug_biguint_to_string( - value: &BigUint, - formatter: &mut std::fmt::Formatter, -) -> Result<(), std::fmt::Error> { - formatter.write_fmt(format_args!("{value}")) -} - #[cfg(test)] mod tests { use { diff --git a/crates/model/src/solver_competition.rs b/crates/model/src/solver_competition.rs index 58a00a732e..6fba23d1ed 100644 --- a/crates/model/src/solver_competition.rs +++ b/crates/model/src/solver_competition.rs @@ -1,6 +1,5 @@ use { crate::{auction::AuctionId, order::OrderUid}, - derivative::Derivative, number::serialization::HexOrDecimalU256, primitive_types::{H160, H256, U256}, serde::{Deserialize, Serialize}, @@ -40,8 +39,7 @@ pub struct CompetitionAuction { } #[serde_as] -#[derive(Clone, Default, Deserialize, Serialize, PartialEq, Derivative)] -#[derivative(Debug)] +#[derive(Clone, Default, Deserialize, Serialize, PartialEq, Debug)] #[serde(rename_all = "camelCase")] pub struct SolverSettlement { pub solver: String, diff --git a/crates/order-validation/Cargo.toml b/crates/order-validation/Cargo.toml index 428e9f8af5..30b46115b0 100644 --- a/crates/order-validation/Cargo.toml +++ b/crates/order-validation/Cargo.toml @@ -6,7 +6,6 @@ edition = "2021" license = "MIT OR Apache-2.0" [dependencies] -cached = { workspace = true } contracts = { path = "../contracts" } ethcontract = { workspace = true } thiserror = { workspace = true } diff --git a/crates/orderbook/Cargo.toml b/crates/orderbook/Cargo.toml index 88ed70160a..9097e76ba5 100644 --- a/crates/orderbook/Cargo.toml +++ b/crates/orderbook/Cargo.toml @@ -28,12 +28,10 @@ contracts = { path = "../contracts" } database = { path = "../database" } ethcontract = { workspace = true } futures = { workspace = true } -gas-estimation = { workspace = true } hex = { workspace = true } hex-literal = { workspace = true } humantime = { workspace = true } hyper = { workspace = true } -maplit = { workspace = true } mimalloc = { workspace = true } model = { path = "../model" } multibase = "0.9" @@ -56,12 +54,9 @@ tokio = { workspace = true, features = ["macros", "rt-multi-thread", "signal", " tracing = { workspace = true } url = { workspace = true } warp = { workspace = true } -web3 = { workspace = true } [dev-dependencies] mockall = { workspace = true } -secp256k1 = { workspace = true } -testlib = { path = "../testlib" } tokio = { workspace = true, features = ["test-util"] } [build-dependencies] diff --git a/crates/refunder/Cargo.toml b/crates/refunder/Cargo.toml index d201b78438..3e6438b84a 100644 --- a/crates/refunder/Cargo.toml +++ b/crates/refunder/Cargo.toml @@ -8,28 +8,23 @@ license = "MIT OR Apache-2.0" [dependencies] anyhow = { workspace = true } async-trait = { workspace = true } -chrono = { workspace = true } clap = { workspace = true } -contracts = { path = "../contracts" } +contracts = { path = "../contracts" } database = { path = "../database" } ethcontract = { workspace = true } ethrpc = { path = "../ethrpc" } -futures = {workspace = true} +futures = { workspace = true } gas-estimation = { workspace = true } humantime = { workspace = true } -lazy_static = { workspace = true } mimalloc = "0.1.43" -model = { path = "../model" } number = { path = "../number" } observe = { path = "../observe" } -primitive-types = { workspace = true } prometheus = { workspace = true } prometheus-metric-storage = { workspace = true } shared = { path = "../shared" } sqlx = { workspace = true } tokio = { workspace = true, features = ["macros", "time", "rt-multi-thread"] } tracing = { workspace = true } -tracing-subscriber = { workspace = true } url = { workspace = true } [lints] diff --git a/crates/shared/Cargo.toml b/crates/shared/Cargo.toml index 104127e75e..f86b75cfd3 100644 --- a/crates/shared/Cargo.toml +++ b/crates/shared/Cargo.toml @@ -21,11 +21,11 @@ clap = { workspace = true } contracts = { path = "../contracts" } dashmap = "6.1.0" database = { path = "../database" } +derive_more = { workspace = true } ttl_cache = "0.5" derivative = { workspace = true } ethcontract = { workspace = true } ethrpc = { path = "../ethrpc" } -flate2 = { workspace = true } futures = { workspace = true } gas-estimation = { workspace = true } observe = { path = "../observe" } @@ -54,18 +54,14 @@ serde_json = { workspace = true } serde_with = { workspace = true } strum = { workspace = true } thiserror = { workspace = true } -time = { workspace = true } tokio = { workspace = true, features = ["macros", "time"] } -tokio-stream = { workspace = true } tracing = { workspace = true } tracing-subscriber = { workspace = true, features = ["env-filter", "fmt", "time"] } url = { workspace = true } -warp = { workspace = true } web3 = { workspace = true } [dev-dependencies] async-stream = "0.3.5" -tempfile = { workspace = true } ethcontract-mock = { workspace = true } regex = { workspace = true } testlib = { path = "../testlib" } diff --git a/crates/shared/src/lib.rs b/crates/shared/src/lib.rs index f56731404c..ed325a2f4e 100644 --- a/crates/shared/src/lib.rs +++ b/crates/shared/src/lib.rs @@ -54,13 +54,6 @@ pub async fn measure_time(future: impl Future, timer: impl FnOnce result } -pub fn debug_bytes( - bytes: impl AsRef<[u8]>, - formatter: &mut std::fmt::Formatter, -) -> Result<(), std::fmt::Error> { - formatter.write_fmt(format_args!("0x{}", hex::encode(bytes.as_ref()))) -} - /// anyhow errors are not clonable natively. This is a workaround that creates a /// new anyhow error based on formatting the error with its inner sources /// without backtrace. diff --git a/crates/shared/src/trade_finding/mod.rs b/crates/shared/src/trade_finding/mod.rs index 2cb4cba961..221964b0e7 100644 --- a/crates/shared/src/trade_finding/mod.rs +++ b/crates/shared/src/trade_finding/mod.rs @@ -1,13 +1,12 @@ //! A module for abstracting a component that can produce a quote with calldata //! for a specified token pair and amount. -#![allow(clippy::needless_lifetimes)] // todo: migrate from derivative to derive_more pub mod external; use { crate::price_estimation::{PriceEstimationError, Query}, anyhow::Result, - derivative::Derivative, + derive_more::Debug, ethcontract::{contract::MethodBuilder, tokens::Tokenize, web3::Transport, Bytes, H160, U256}, model::interaction::InteractionData, serde::Serialize, @@ -51,12 +50,11 @@ pub struct Trade { } /// Data for a raw GPv2 interaction. -#[derive(Clone, PartialEq, Eq, Hash, Default, Serialize, Derivative)] -#[derivative(Debug)] +#[derive(Clone, PartialEq, Eq, Hash, Default, Serialize, Debug)] pub struct Interaction { pub target: H160, pub value: U256, - #[derivative(Debug(format_with = "crate::debug_bytes"))] + #[debug("0x{}", hex::encode::<&[u8]>(data.as_ref()))] pub data: Vec, } @@ -142,3 +140,25 @@ impl Clone for TradeError { pub fn map_interactions(interactions: &[InteractionData]) -> Vec { interactions.iter().cloned().map(Into::into).collect() } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_debug_interaction() { + let interaction = Interaction { + target: H160::zero(), + value: U256::one(), + data: vec![0x01, 0x02, 0x03, 0x04, 0x05, 0x06], + }; + + let interaction_debug = format!("{:?}", interaction); + + assert_eq!( + interaction_debug, + "Interaction { target: 0x0000000000000000000000000000000000000000, value: 1, data: \ + 0x010203040506 }" + ); + } +} diff --git a/crates/solver/Cargo.toml b/crates/solver/Cargo.toml index cbb488c755..aa80153249 100644 --- a/crates/solver/Cargo.toml +++ b/crates/solver/Cargo.toml @@ -14,21 +14,14 @@ doctest = false anyhow = { workspace = true } arc-swap = "1.7.1" async-trait = { workspace = true } -chrono = { workspace = true, features = ["clock"] } -clap = { workspace = true } contracts = { path = "../contracts" } -derivative = { workspace = true } ethcontract = { workspace = true } ethrpc = { path = "../ethrpc" } -flate2 = { workspace = true } futures = { workspace = true } -gas-estimation = { workspace = true } observe = { path = "../observe" } hex = { workspace = true } hex-literal = { workspace = true } -humantime = { workspace = true } itertools = { workspace = true } -jsonrpc-core = "18" lazy_static = { workspace = true } maplit = { workspace = true } mockall = { workspace = true } @@ -39,24 +32,17 @@ once_cell = { workspace = true } primitive-types = { workspace = true } prometheus = { workspace = true } prometheus-metric-storage = { workspace = true } -rand = { workspace = true } -rate-limit = { path = "../rate-limit" } -reqwest = { workspace = true, features = ["json"] } serde = { workspace = true } serde_json = { workspace = true } -serde_with = { workspace = true } shared = { path = "../shared" } strum = { workspace = true } -thiserror = { workspace = true } tokio = { workspace = true, features = ["macros", "rt-multi-thread", "time"] } tracing = { workspace = true } -url = { workspace = true } web3 = { workspace = true } [dev-dependencies] -ethcontract-mock = { workspace = true } +derivative = { workspace = true } tokio = { workspace = true, features = ["test-util"] } -tracing-subscriber = { workspace = true } testlib = { path = "../testlib" } [lints] diff --git a/crates/solvers/Cargo.toml b/crates/solvers/Cargo.toml index 54eb233926..46bf8a143e 100644 --- a/crates/solvers/Cargo.toml +++ b/crates/solvers/Cargo.toml @@ -21,7 +21,6 @@ clap = { workspace = true, features = ["derive", "env"] } derive_more = { workspace = true } ethereum-types = { workspace = true } ethrpc = { path = "../ethrpc" } -futures = { workspace = true } hex = { workspace = true } hyper = { workspace = true } itertools = { workspace = true } @@ -29,14 +28,11 @@ mimalloc = { workspace = true } num = { workspace = true } prometheus = { workspace = true } prometheus-metric-storage = { workspace = true } -rate-limit = { path = "../rate-limit" } reqwest = { workspace = true } -s3 = { path = "../s3" } serde = { workspace = true } serde_json = { workspace = true } serde_with = { workspace = true } solvers-dto = { path = "../solvers-dto" } -thiserror = { workspace = true } tokio = { workspace = true, features = ["macros", "rt-multi-thread", "signal", "time"] } toml = { workspace = true } tower = "0.4"