From 2a0af6c7335a23814f8003b8a591a49ebb58a9f0 Mon Sep 17 00:00:00 2001 From: adrian Date: Fri, 12 Sep 2025 08:22:28 +0200 Subject: [PATCH] feat: upgrade tycho deps in protocol-testing --- protocol-testing/Cargo.lock | 42 ++++++++++++++--------------- protocol-testing/Cargo.toml | 6 ++--- protocol-testing/run.Dockerfile | 2 +- protocol-testing/src/encoding.rs | 26 ++++++++++-------- protocol-testing/src/test_runner.rs | 4 +-- 5 files changed, 42 insertions(+), 38 deletions(-) diff --git a/protocol-testing/Cargo.lock b/protocol-testing/Cargo.lock index c2f1e6b..baac3e4 100644 --- a/protocol-testing/Cargo.lock +++ b/protocol-testing/Cargo.lock @@ -2809,7 +2809,7 @@ dependencies = [ "libc", "option-ext", "redox_users", - "windows-sys 0.59.0", + "windows-sys 0.60.2", ] [[package]] @@ -4590,7 +4590,7 @@ checksum = "e04d7f318608d35d4b61ddd75cbdaee86b023ebe2bd5a66ee0915f0bf93095a9" dependencies = [ "hermit-abi 0.5.2", "libc", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -4650,7 +4650,7 @@ dependencies = [ "portable-atomic", "portable-atomic-util", "serde", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -5891,7 +5891,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a56d757972c98b346a9b766e3f02746cde6dd1cd1d1d563472929fdd74bec4d" dependencies = [ "anyhow", - "itertools 0.10.5", + "itertools 0.14.0", "proc-macro2", "quote", "syn 2.0.99", @@ -5904,7 +5904,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9120690fafc389a67ba3803df527d0ec9cbbc9cc45e4cc20b332996dfb672425" dependencies = [ "anyhow", - "itertools 0.10.5", + "itertools 0.14.0", "proc-macro2", "quote", "syn 2.0.99", @@ -6008,7 +6008,7 @@ dependencies = [ "quinn-udp", "rustc-hash", "rustls", - "socket2 0.5.8", + "socket2 0.6.0", "thiserror 2.0.12", "tokio", "tracing", @@ -6045,9 +6045,9 @@ dependencies = [ "cfg_aliases", "libc", "once_cell", - "socket2 0.5.8", + "socket2 0.6.0", "tracing", - "windows-sys 0.52.0", + "windows-sys 0.60.2", ] [[package]] @@ -7343,7 +7343,7 @@ dependencies = [ "derive_more", "dunce", "inturn", - "itertools 0.10.5", + "itertools 0.14.0", "itoa", "match_cfg", "normalize-path", @@ -7352,7 +7352,7 @@ dependencies = [ "solar-config", "solar-data-structures", "solar-macros", - "thiserror 1.0.69", + "thiserror 2.0.12", "tracing", "unicode-width 0.2.0", ] @@ -7377,7 +7377,7 @@ dependencies = [ "alloy-primitives", "bitflags 2.9.4", "bumpalo", - "itertools 0.10.5", + "itertools 0.14.0", "memchr", "num-bigint", "num-rational", @@ -7647,7 +7647,7 @@ dependencies = [ "serde_json", "sha2 0.10.9", "tempfile", - "thiserror 1.0.69", + "thiserror 2.0.12", "url", "zip", ] @@ -8380,9 +8380,9 @@ dependencies = [ [[package]] name = "tycho-client" -version = "0.82.0" +version = "0.83.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19a7ed885ea7e01efc3c98135b1be5c0472e81ada6455517f61ca67313271587" +checksum = "3da113f5301ba1fb8e4441df405afa1e7b728a83017681b94851c5bc36d758dc" dependencies = [ "anyhow", "async-trait", @@ -8407,9 +8407,9 @@ dependencies = [ [[package]] name = "tycho-common" -version = "0.82.0" +version = "0.83.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "096c87ebe011785fcd7ed59ec501ac12b465a64fbd2914b8c0c57125c253682b" +checksum = "75ecbbf6f701a01569e351d19ee3a3e36418e8d1be539fd6ed925137eb84a2b2" dependencies = [ "anyhow", "async-trait", @@ -8432,9 +8432,9 @@ dependencies = [ [[package]] name = "tycho-execution" -version = "0.122.0" +version = "0.124.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81e88fe8ee0d32032e0270804c8fd8d4b56fa5055daa6a64720cd4c39c3984e1" +checksum = "9da3bca6f82da18f6e59a995ba1dfe416a070a0e0a1dc58ef5bc5a9f288de783" dependencies = [ "alloy", "chrono", @@ -8454,8 +8454,8 @@ dependencies = [ [[package]] name = "tycho-simulation" -version = "0.157.1" -source = "git+https://github.com/propeller-heads/tycho-simulation.git?tag=0.157.1#02ef8fbdfde4cc0f65f08880e108f292643acb64" +version = "0.158.0" +source = "git+https://github.com/propeller-heads/tycho-simulation.git?tag=0.158.0#bf864f437c9eb3014449146b86628c2251adce61" dependencies = [ "alloy", "async-stream", @@ -9053,7 +9053,7 @@ version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" dependencies = [ - "windows-sys 0.52.0", + "windows-sys 0.60.2", ] [[package]] diff --git a/protocol-testing/Cargo.toml b/protocol-testing/Cargo.toml index 5a417a8..e74c65c 100644 --- a/protocol-testing/Cargo.toml +++ b/protocol-testing/Cargo.toml @@ -9,9 +9,9 @@ miette = { version = "7.6.0", features = ["fancy"] } # Logging & Tracing tracing = "0.1.37" # Tycho dependencies -tycho-common = "0.82.0" -tycho-client = "0.82.0" -tycho-simulation = { git = "https://github.com/propeller-heads/tycho-simulation.git", tag = "0.157.1", features = ["evm"] } +tycho-common = "0.83.4" +tycho-client = "0.83.4" +tycho-simulation = { git = "https://github.com/propeller-heads/tycho-simulation.git", tag = "0.158.0", features = ["evm"] } ## TODO: for local development #tycho-simulation = { path = "../../tycho-simulation" } num-bigint = "0.4" diff --git a/protocol-testing/run.Dockerfile b/protocol-testing/run.Dockerfile index 31d5317..023f8e6 100644 --- a/protocol-testing/run.Dockerfile +++ b/protocol-testing/run.Dockerfile @@ -4,7 +4,7 @@ FROM rust:1.89-bookworm AS tycho-indexer-builder WORKDIR /build RUN apt-get update && apt-get install -y git -RUN git clone --depth 1 --branch "0.83.3" https://github.com/propeller-heads/tycho-indexer.git +RUN git clone --depth 1 --branch "0.83.4" https://github.com/propeller-heads/tycho-indexer.git WORKDIR /build/tycho-indexer RUN cargo build --release --bin tycho-indexer diff --git a/protocol-testing/src/encoding.rs b/protocol-testing/src/encoding.rs index 3d0e04c..e6d4597 100644 --- a/protocol-testing/src/encoding.rs +++ b/protocol-testing/src/encoding.rs @@ -1,6 +1,7 @@ use std::str::FromStr; use alloy::{primitives::Keccak256, sol_types::SolValue}; +use miette::{miette, IntoDiagnostic, WrapErr}; use num_bigint::BigUint; use tycho_common::{dto::Chain, Bytes}; use tycho_simulation::{ @@ -17,35 +18,36 @@ use tycho_simulation::{ /// Encodes swap data for the Tycho router. /// -/// Assumes a single swap solution and encodes the data ready to be used by the Tycho router directly. +/// Assumes a single swap solution and encodes the data ready to be used by the Tycho router +/// directly. /// /// # Parameters /// - `component`: The protocol component to swap through -/// - `token_in`: Input token address +/// - `token_in`: Input token address /// - `token_out`: Output token address /// - `amount_in`: Amount of input token to swap /// - `amount_out`: Expected amount of output token /// /// # Returns -/// A `Result` containing the encoded transaction data for the Tycho router, -/// or an error if encoding fails. +/// A `Result` containing the encoded transaction data for the Tycho +/// router, or an error if encoding fails. pub fn encode_swap( component: ProtocolComponent, token_in: Bytes, token_out: Bytes, amount_in: BigUint, amount_out: BigUint, -) -> Result { +) -> miette::Result { let chain: tycho_common::models::Chain = Chain::Ethereum.into(); - let alice_address = - Bytes::from_str("0xcd09f75E2BF2A4d11F3AB23f1389FcC1621c0cc2").map_err(|_| { - EncodingError::FatalError("Alice's address can't be converted to Bytes".to_string()) - })?; + let alice_address = Bytes::from_str("0xcd09f75E2BF2A4d11F3AB23f1389FcC1621c0cc2") + .into_diagnostic() + .wrap_err(miette!("Failed to parse Alice's address for Tycho router encoding"))?; let encoder = TychoRouterEncoderBuilder::new() .chain(chain) .user_transfer_type(UserTransferType::TransferFrom) .build() - .expect("Failed to build encoder"); + .into_diagnostic() + .wrap_err(miette!("Failed to build encoder"))?; let swap = SwapBuilder::new(component, token_in.clone(), token_out.clone()).build(); @@ -69,10 +71,12 @@ pub fn encode_swap( let encoded_solution = encoder .encode_solutions(vec![solution.clone()]) - .expect("Failed to encode router calldata")[0] + .into_diagnostic() + .wrap_err(miette!("Failed to encode router calldata"))?[0] .clone(); encode_tycho_router_call(encoded_solution, &solution, &chain.wrapped_native_token().address) + .into_diagnostic() } /// Encodes a transaction for the Tycho Router using `singleSwap` method and regular token diff --git a/protocol-testing/src/test_runner.rs b/protocol-testing/src/test_runner.rs index 6db4483..4696c89 100644 --- a/protocol-testing/src/test_runner.rs +++ b/protocol-testing/src/test_runner.rs @@ -533,13 +533,13 @@ fn validate_state( let protocol_component = block_msg.new_pairs.get(id); if let Some(pc) = protocol_component { - let calldata = encode_swap( + encode_swap( pc.clone(), token_in.address.clone(), token_out.address.clone(), amount_in, amount_out_result.amount, - ); + )?; info!("Encoded swap successfully"); } }