From 23875b8b02396690b3f028c7696ea5b95e17e40e Mon Sep 17 00:00:00 2001 From: Diana Carvalho Date: Tue, 4 Feb 2025 13:30:01 +0000 Subject: [PATCH 1/6] feat: Refactor Registries Interface changes: - Rename StrategySelector to StrategyEncoderRegistry - Implement clone for SwapEncoder The StrategyEncoderRegistry needs to be initialised at the highest level and the passed to the TychoEncoder. The TychoEncoder doesn't hold the chain nor the signer_pk as attributes anymore The StrategyEncoderRegistry does: - Initialises the SwapEncoderRegistry - Initialises all the strategies and saves them in a HashMap - Later, the TychoEncoder only reads from this hashmap The StrategyEncoder now each holds a SwapEncoderRegistry as an attribute and they use this to get the correct SwapEncoder instead of reading from the global SWAP_ENCODER_REGISTRY Simplified the SwapEncoderRegistry to not need a Config (everything is done inside itself) All SwapEncoders implement clone Took 2 hours 29 minutes Took 11 seconds Took 2 minutes --- examples/quickstart/main.rs | 13 +++- src/encoding/config/executor_addresses.json | 8 +- src/encoding/evm/strategy_encoder/mod.rs | 2 +- .../strategy_encoder_registry.rs | 53 +++++++++++++ .../evm/strategy_encoder/strategy_encoders.rs | 77 +++++++++++++------ .../evm/strategy_encoder/strategy_selector.rs | 30 -------- src/encoding/evm/swap_encoder/builder.rs | 8 +- src/encoding/evm/swap_encoder/mod.rs | 18 +---- src/encoding/evm/swap_encoder/registry.rs | 31 ++------ .../evm/swap_encoder/swap_encoders.rs | 13 ++++ src/encoding/evm/tycho_encoder.rs | 64 +++++++-------- src/encoding/mod.rs | 2 +- src/encoding/strategy_encoder.rs | 20 +++-- src/encoding/swap_encoder.rs | 11 ++- src/encoding/tycho_encoder.rs | 4 +- 15 files changed, 206 insertions(+), 148 deletions(-) create mode 100644 src/encoding/evm/strategy_encoder/strategy_encoder_registry.rs delete mode 100644 src/encoding/evm/strategy_encoder/strategy_selector.rs diff --git a/examples/quickstart/main.rs b/examples/quickstart/main.rs index 5b46e1d..ee89104 100644 --- a/examples/quickstart/main.rs +++ b/examples/quickstart/main.rs @@ -4,9 +4,11 @@ use num_bigint::BigUint; use tycho_core::{dto::ProtocolComponent, models::Chain, Bytes}; use tycho_execution::encoding::{ evm::{ - strategy_encoder::strategy_selector::EVMStrategySelector, tycho_encoder::EVMTychoEncoder, + strategy_encoder::strategy_encoder_registry::EVMStrategyEncoderRegistry, + tycho_encoder::EVMTychoEncoder, }, models::{Solution, Swap}, + strategy_encoder::StrategyEncoderRegistry, tycho_encoder::TychoEncoder, }; @@ -17,11 +19,14 @@ fn main() { Some("0x123456789abcdef123456789abcdef123456789abcdef123456789abcdef1234".to_string()); let user_address = Bytes::from_str("0xcd09f75E2BF2A4d11F3AB23f1389FcC1621c0cc2") .expect("Failed to create user address"); + let executors_file_path = "src/encoding/config/executor_addresses.json"; // Initialize the encoder - let encoder = - EVMTychoEncoder::new(EVMStrategySelector, router_address, signer_pk, Chain::Ethereum) - .expect("Failed to create encoder"); + let strategy_encoder_registry = + EVMStrategyEncoderRegistry::new(Chain::Ethereum, executors_file_path, signer_pk.clone()) + .expect("Failed to create strategy encoder registry"); + let encoder = EVMTychoEncoder::new(strategy_encoder_registry, router_address) + .expect("Failed to create encoder"); // ------------------- Encode a simple swap ------------------- diff --git a/src/encoding/config/executor_addresses.json b/src/encoding/config/executor_addresses.json index 1be7d99..6e27a2d 100644 --- a/src/encoding/config/executor_addresses.json +++ b/src/encoding/config/executor_addresses.json @@ -1,8 +1,6 @@ { - "executors": { - "ethereum": { - "uniswap_v2": "0x5C2F5a71f67c01775180ADc06909288B4C329308", - "vm:balancer_v2": "0x543778987b293C7E8Cf0722BB2e935ba6f4068D4" - } + "ethereum": { + "uniswap_v2": "0x5C2F5a71f67c01775180ADc06909288B4C329308", + "vm:balancer_v2": "0x543778987b293C7E8Cf0722BB2e935ba6f4068D4" } } \ No newline at end of file diff --git a/src/encoding/evm/strategy_encoder/mod.rs b/src/encoding/evm/strategy_encoder/mod.rs index 0142707..a0cf652 100644 --- a/src/encoding/evm/strategy_encoder/mod.rs +++ b/src/encoding/evm/strategy_encoder/mod.rs @@ -1,2 +1,2 @@ +pub mod strategy_encoder_registry; mod strategy_encoders; -pub mod strategy_selector; diff --git a/src/encoding/evm/strategy_encoder/strategy_encoder_registry.rs b/src/encoding/evm/strategy_encoder/strategy_encoder_registry.rs new file mode 100644 index 0000000..cb11fa0 --- /dev/null +++ b/src/encoding/evm/strategy_encoder/strategy_encoder_registry.rs @@ -0,0 +1,53 @@ +use std::collections::HashMap; + +use tycho_core::models::Chain; + +use crate::encoding::{ + errors::EncodingError, + evm::{ + strategy_encoder::strategy_encoders::{ExecutorStrategyEncoder, SplitSwapStrategyEncoder}, + swap_encoder::registry::SwapEncoderRegistry, + }, + models::Solution, + strategy_encoder::{StrategyEncoder, StrategyEncoderRegistry}, +}; + +pub struct EVMStrategyEncoderRegistry { + strategies: HashMap>, +} + +impl StrategyEncoderRegistry for EVMStrategyEncoderRegistry { + fn new( + chain: Chain, + executors_file_path: &str, + signer_pk: Option, + ) -> Result { + let swap_encoder_registry = SwapEncoderRegistry::new(executors_file_path, Chain::Ethereum)?; + + let mut strategies: HashMap> = HashMap::new(); + strategies.insert( + "executor".to_string(), + Box::new(ExecutorStrategyEncoder::new(swap_encoder_registry.clone())), + ); + if let Some(signer) = signer_pk { + strategies.insert( + "split_swap".to_string(), + Box::new( + SplitSwapStrategyEncoder::new(signer, chain, swap_encoder_registry).unwrap(), + ), + ); + } + Ok(Self { strategies }) + } + fn get_encoder(&self, solution: &Solution) -> Result<&Box, EncodingError> { + if solution.direct_execution { + self.strategies + .get("executor") + .ok_or(EncodingError::FatalError("Executor strategy not found".to_string())) + } else { + self.strategies + .get("split_swap") + .ok_or(EncodingError::FatalError("Split swap strategy not found. Please pass the signer private key to the StrategySelector constructor".to_string())) + } + } +} diff --git a/src/encoding/evm/strategy_encoder/strategy_encoders.rs b/src/encoding/evm/strategy_encoder/strategy_encoders.rs index 8dc9eb7..d65d926 100644 --- a/src/encoding/evm/strategy_encoder/strategy_encoders.rs +++ b/src/encoding/evm/strategy_encoder/strategy_encoders.rs @@ -10,11 +10,12 @@ use crate::encoding::{ evm::{ approvals::permit2::Permit2, constants::WETH_ADDRESS, - swap_encoder::SWAP_ENCODER_REGISTRY, + swap_encoder::registry::SwapEncoderRegistry, utils::{biguint_to_u256, bytes_to_address, encode_input, percentage_to_uint24}, }, models::{EncodingContext, NativeAction, Solution}, strategy_encoder::StrategyEncoder, + swap_encoder::SwapEncoder, }; pub trait EVMStrategyEncoder: StrategyEncoder { @@ -54,14 +55,19 @@ pub trait EVMStrategyEncoder: StrategyEncoder { } pub struct SplitSwapStrategyEncoder { + swap_encoder_registry: SwapEncoderRegistry, permit2: Permit2, selector: String, } impl SplitSwapStrategyEncoder { - pub fn new(signer_pk: String, chain: Chain) -> Result { + pub fn new( + signer_pk: String, + chain: Chain, + swap_encoder_registry: SwapEncoderRegistry, + ) -> Result { let selector = "swap(uint256,address,address,uint256,bool,bool,uint256,address,((address,uint160,uint48,uint48),address,uint256),bytes,bytes)".to_string(); - Ok(Self { permit2: Permit2::new(signer_pk, chain)?, selector }) + Ok(Self { permit2: Permit2::new(signer_pk, chain)?, selector, swap_encoder_registry }) } } impl EVMStrategyEncoder for SplitSwapStrategyEncoder {} @@ -134,16 +140,14 @@ impl StrategyEncoder for SplitSwapStrategyEncoder { let mut swaps = vec![]; for swap in solution.swaps.iter() { - let registry = SWAP_ENCODER_REGISTRY - .read() - .map_err(|_| { - EncodingError::FatalError( - "Failed to read the swap encoder registry".to_string(), - ) + let swap_encoder = self + .get_swap_encoder(&swap.component.protocol_system) + .ok_or_else(|| { + EncodingError::InvalidInput(format!( + "Swap encoder not found for protocol: {}", + swap.component.protocol_system + )) })?; - let swap_encoder = registry - .get_encoder(&swap.component.protocol_system) - .expect("Swap encoder not found"); let encoding_context = EncodingContext { receiver: router_address.clone(), @@ -201,11 +205,24 @@ impl StrategyEncoder for SplitSwapStrategyEncoder { let contract_interaction = encode_input(&self.selector, method_calldata); Ok((contract_interaction, router_address)) } + + fn get_swap_encoder(&self, protocol_system: &str) -> Option<&Box> { + self.swap_encoder_registry + .get_encoder(protocol_system) + } } /// This strategy encoder is used for solutions that are sent directly to the pool. /// Only 1 solution with 1 swap is supported. -pub struct ExecutorStrategyEncoder {} +pub struct ExecutorStrategyEncoder { + swap_encoder_registry: SwapEncoderRegistry, +} + +impl ExecutorStrategyEncoder { + pub fn new(swap_encoder_registry: SwapEncoderRegistry) -> Self { + Self { swap_encoder_registry } + } +} impl EVMStrategyEncoder for ExecutorStrategyEncoder {} impl StrategyEncoder for ExecutorStrategyEncoder { fn encode_strategy( @@ -223,13 +240,9 @@ impl StrategyEncoder for ExecutorStrategyEncoder { .swaps .first() .ok_or_else(|| EncodingError::InvalidInput("No swaps found in solution".to_string()))?; - let registry = SWAP_ENCODER_REGISTRY - .read() - .map_err(|_| { - EncodingError::FatalError("Failed to read the swap encoder registry".to_string()) - })?; - let swap_encoder = registry - .get_encoder(&swap.component.protocol_system) + + let swap_encoder = self + .get_swap_encoder(&swap.component.protocol_system) .ok_or_else(|| { EncodingError::InvalidInput(format!( "Swap encoder not found for protocol: {}", @@ -248,6 +261,10 @@ impl StrategyEncoder for ExecutorStrategyEncoder { .map_err(|_| EncodingError::FatalError("Invalid executor address".to_string()))?; Ok((protocol_data, executor_address)) } + fn get_swap_encoder(&self, protocol_system: &str) -> Option<&Box> { + self.swap_encoder_registry + .get_encoder(protocol_system) + } } #[cfg(test)] @@ -265,9 +282,15 @@ mod tests { models::Swap, }; + fn get_swap_encoder_registry() -> SwapEncoderRegistry { + SwapEncoderRegistry::new("src/encoding/config/executor_addresses.json", Chain::Ethereum) + .unwrap() + } + #[test] fn test_executor_strategy_encode() { - let encoder = ExecutorStrategyEncoder {}; + let swap_encoder_registry = get_swap_encoder_registry(); + let encoder = ExecutorStrategyEncoder::new(swap_encoder_registry); let token_in = Bytes::from("0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"); let token_out = Bytes::from("0x6b175474e89094c44da98b954eedeac495271d0f"); @@ -373,8 +396,10 @@ mod tests { token_out: dai.clone(), split: 0f64, }; - - let encoder = SplitSwapStrategyEncoder::new(private_key, Chain::Ethereum).unwrap(); + let swap_encoder_registry = get_swap_encoder_registry(); + let encoder = + SplitSwapStrategyEncoder::new(private_key, Chain::Ethereum, swap_encoder_registry) + .unwrap(); let solution = Solution { exact_out: false, given_token: weth, @@ -608,8 +633,10 @@ mod tests { token_out: usdc.clone(), split: 0f64, }; - - let encoder = SplitSwapStrategyEncoder::new(private_key, Chain::Ethereum).unwrap(); + let swap_encoder_registry = get_swap_encoder_registry(); + let encoder = + SplitSwapStrategyEncoder::new(private_key, Chain::Ethereum, swap_encoder_registry) + .unwrap(); let solution = Solution { exact_out: false, given_token: weth, diff --git a/src/encoding/evm/strategy_encoder/strategy_selector.rs b/src/encoding/evm/strategy_encoder/strategy_selector.rs deleted file mode 100644 index 3ba9de3..0000000 --- a/src/encoding/evm/strategy_encoder/strategy_selector.rs +++ /dev/null @@ -1,30 +0,0 @@ -use tycho_core::models::Chain; - -use crate::encoding::{ - errors::EncodingError, - evm::strategy_encoder::strategy_encoders::{ExecutorStrategyEncoder, SplitSwapStrategyEncoder}, - models::Solution, - strategy_encoder::{StrategyEncoder, StrategySelector}, -}; - -pub struct EVMStrategySelector; - -impl StrategySelector for EVMStrategySelector { - fn select_strategy( - &self, - solution: &Solution, - signer: Option, - chain: Chain, - ) -> Result, EncodingError> { - if solution.direct_execution { - Ok(Box::new(ExecutorStrategyEncoder {})) - } else { - let signer_pk = signer.ok_or_else(|| { - EncodingError::FatalError( - "Signer is required for SplitSwapStrategyEncoder".to_string(), - ) - })?; - Ok(Box::new(SplitSwapStrategyEncoder::new(signer_pk, chain)?)) - } - } -} diff --git a/src/encoding/evm/swap_encoder/builder.rs b/src/encoding/evm/swap_encoder/builder.rs index cd5525b..d0b8eeb 100644 --- a/src/encoding/evm/swap_encoder/builder.rs +++ b/src/encoding/evm/swap_encoder/builder.rs @@ -1,4 +1,5 @@ use crate::encoding::{ + errors::EncodingError, evm::swap_encoder::swap_encoders::{BalancerV2SwapEncoder, UniswapV2SwapEncoder}, swap_encoder::SwapEncoder, }; @@ -16,11 +17,14 @@ impl SwapEncoderBuilder { } } - pub fn build(self) -> Result, String> { + pub fn build(self) -> Result, EncodingError> { match self.protocol_system.as_str() { "uniswap_v2" => Ok(Box::new(UniswapV2SwapEncoder::new(self.executor_address))), "vm:balancer_v2" => Ok(Box::new(BalancerV2SwapEncoder::new(self.executor_address))), - _ => Err(format!("Unknown protocol system: {}", self.protocol_system)), + _ => Err(EncodingError::FatalError(format!( + "Unknown protocol system: {}", + self.protocol_system + ))), } } } diff --git a/src/encoding/evm/swap_encoder/mod.rs b/src/encoding/evm/swap_encoder/mod.rs index 1148d2d..8d5bb3a 100644 --- a/src/encoding/evm/swap_encoder/mod.rs +++ b/src/encoding/evm/swap_encoder/mod.rs @@ -1,19 +1,3 @@ mod builder; -mod registry; +pub mod registry; mod swap_encoders; - -use std::sync::RwLock; - -use lazy_static::lazy_static; -use tycho_core::dto::Chain; - -use crate::encoding::evm::swap_encoder::registry::{Config, SwapEncoderRegistry}; - -// TODO: init this at the higher level at some point -lazy_static! { - pub static ref SWAP_ENCODER_REGISTRY: RwLock = { - let config = Config::from_file("src/encoding/config/executor_addresses.json") - .expect("Failed to load configuration file"); - RwLock::new(SwapEncoderRegistry::new(config, Chain::Ethereum)) - }; -} diff --git a/src/encoding/evm/swap_encoder/registry.rs b/src/encoding/evm/swap_encoder/registry.rs index 06e6147..639dfc0 100644 --- a/src/encoding/evm/swap_encoder/registry.rs +++ b/src/encoding/evm/swap_encoder/registry.rs @@ -1,33 +1,32 @@ use std::{collections::HashMap, fs}; -use serde::Deserialize; -use tycho_core::dto::Chain; +use tycho_core::models::Chain; use crate::encoding::{ errors::EncodingError, evm::swap_encoder::builder::SwapEncoderBuilder, swap_encoder::SwapEncoder, }; +#[derive(Clone)] pub struct SwapEncoderRegistry { encoders: HashMap>, } impl SwapEncoderRegistry { - pub fn new(config: Config, blockchain: Chain) -> Self { + pub fn new(executors_file_path: &str, blockchain: Chain) -> Result { + let config_str = fs::read_to_string(executors_file_path)?; + let config: HashMap> = serde_json::from_str(&config_str)?; let mut encoders = HashMap::new(); let executors = config - .executors .get(&blockchain) - .unwrap_or_else(|| panic!("No executors found for blockchain: {}", blockchain)); + .ok_or(EncodingError::FatalError("No executors found for blockchain".to_string()))?; for (protocol, executor_address) in executors { let builder = SwapEncoderBuilder::new(protocol, executor_address); - let encoder = builder.build().unwrap_or_else(|_| { - panic!("Failed to build swap encoder for protocol: {}", protocol) - }); + let encoder = builder.build()?; encoders.insert(protocol.to_string(), encoder); } - Self { encoders } + Ok(Self { encoders }) } #[allow(clippy::borrowed_box)] @@ -35,17 +34,3 @@ impl SwapEncoderRegistry { self.encoders.get(protocol_system) } } - -#[derive(Deserialize)] -pub struct Config { - pub executors: HashMap>, /* Blockchain -> {Protocol -> - * Executor address} mapping */ -} - -impl Config { - pub fn from_file(path: &str) -> Result { - let config_str = fs::read_to_string(path)?; - let config: Config = serde_json::from_str(&config_str)?; - Ok(config) - } -} diff --git a/src/encoding/evm/swap_encoder/swap_encoders.rs b/src/encoding/evm/swap_encoder/swap_encoders.rs index 432b2b0..e3c573f 100644 --- a/src/encoding/evm/swap_encoder/swap_encoders.rs +++ b/src/encoding/evm/swap_encoder/swap_encoders.rs @@ -12,6 +12,7 @@ use crate::encoding::{ swap_encoder::SwapEncoder, }; +#[derive(Clone)] pub struct UniswapV2SwapEncoder { executor_address: String, executor_selector: String, @@ -59,8 +60,13 @@ impl SwapEncoder for UniswapV2SwapEncoder { fn executor_selector(&self) -> &str { &self.executor_selector } + + fn clone_box(&self) -> Box { + Box::new(self.clone()) + } } +#[derive(Clone)] pub struct UniswapV3SwapEncoder { executor_address: String, executor_selector: String, @@ -129,8 +135,12 @@ impl SwapEncoder for UniswapV3SwapEncoder { fn executor_selector(&self) -> &str { &self.executor_selector } + fn clone_box(&self) -> Box { + Box::new(self.clone()) + } } +#[derive(Clone)] pub struct BalancerV2SwapEncoder { executor_address: String, executor_selector: String, @@ -179,6 +189,9 @@ impl SwapEncoder for BalancerV2SwapEncoder { fn executor_selector(&self) -> &str { &self.executor_selector } + fn clone_box(&self) -> Box { + Box::new(self.clone()) + } } #[cfg(test)] diff --git a/src/encoding/evm/tycho_encoder.rs b/src/encoding/evm/tycho_encoder.rs index 3006ee3..3e41208 100644 --- a/src/encoding/evm/tycho_encoder.rs +++ b/src/encoding/evm/tycho_encoder.rs @@ -1,33 +1,26 @@ use std::str::FromStr; use num_bigint::BigUint; -use tycho_core::{models::Chain, Bytes}; +use tycho_core::Bytes; use crate::encoding::{ errors::EncodingError, evm::constants::{NATIVE_ADDRESS, WETH_ADDRESS}, models::{NativeAction, Solution, Transaction}, - strategy_encoder::StrategySelector, + strategy_encoder::StrategyEncoderRegistry, tycho_encoder::TychoEncoder, }; -pub struct EVMTychoEncoder { +pub struct EVMTychoEncoder { strategy_selector: S, - signer_pk: Option, - chain: Chain, router_address: Bytes, } -impl EVMTychoEncoder { - pub fn new( - strategy_selector: S, - router_address: String, - signer_pk: Option, - chain: Chain, - ) -> Result { +impl EVMTychoEncoder { + pub fn new(strategy_selector: S, router_address: String) -> Result { let router_address = Bytes::from_str(&router_address) .map_err(|_| EncodingError::FatalError("Invalid router address".to_string()))?; - Ok(EVMTychoEncoder { strategy_selector, signer_pk, chain, router_address }) + Ok(EVMTychoEncoder { strategy_selector, router_address }) } } @@ -74,7 +67,7 @@ impl EVMTychoEncoder { } } -impl TychoEncoder for EVMTychoEncoder { +impl TychoEncoder for EVMTychoEncoder { fn encode_router_calldata( &self, solutions: Vec, @@ -88,11 +81,9 @@ impl TychoEncoder for EVMTychoEncoder { .clone() .unwrap_or(self.router_address.clone()); - let strategy = self.strategy_selector.select_strategy( - solution, - self.signer_pk.clone(), - self.chain, - )?; + let strategy = self + .strategy_selector + .get_encoder(solution)?; let (contract_interaction, target_address) = strategy.encode_strategy(solution.clone(), router_address)?; @@ -113,25 +104,36 @@ impl TychoEncoder for EVMTychoEncoder { #[cfg(test)] mod tests { + use tycho_core::models::Chain; + use tycho_core::dto::ProtocolComponent; use super::*; + use crate::encoding::{strategy_encoder::StrategyEncoder, swap_encoder::SwapEncoder}; use crate::encoding::{models::Swap, strategy_encoder::StrategyEncoder}; - struct MockStrategySelector; + struct MockStrategyRegistry { + strategy: Box, + } fn dai() -> Bytes { Bytes::from_str("0x6b175474e89094c44da98b954eedeac495271d0f").unwrap() } - impl StrategySelector for MockStrategySelector { - fn select_strategy( + impl StrategyEncoderRegistry for MockStrategyRegistry { + fn new( + _chain: Chain, + _executors_file_path: &str, + _signer_pk: Option, + ) -> Result { + Ok(Self { strategy: Box::new(MockStrategy) }) + } + + fn get_encoder( &self, _solution: &Solution, - _signer: Option, - _chain: Chain, - ) -> Result, EncodingError> { - Ok(Box::new(MockStrategy)) + ) -> Result<&Box, EncodingError> { + Ok(&self.strategy) } } @@ -150,15 +152,17 @@ mod tests { Bytes::from_str("0xabcd").unwrap(), )) } + + fn get_swap_encoder(&self, _protocol_system: &str) -> Option<&Box> { + None + } } - fn get_mocked_tycho_encoder() -> EVMTychoEncoder { - let strategy_selector = MockStrategySelector; + fn get_mocked_tycho_encoder() -> EVMTychoEncoder { + let strategy_selector = MockStrategyRegistry::new(Chain::Ethereum, "", None).unwrap(); EVMTychoEncoder::new( strategy_selector, "0x1234567890abcdef1234567890abcdef12345678".to_string(), - Some("0xabcdef".to_string()), - Chain::Ethereum, ) .unwrap() } diff --git a/src/encoding/mod.rs b/src/encoding/mod.rs index 255b40d..502e336 100644 --- a/src/encoding/mod.rs +++ b/src/encoding/mod.rs @@ -2,6 +2,6 @@ mod errors; #[cfg(feature = "evm")] pub mod evm; pub mod models; -mod strategy_encoder; +pub mod strategy_encoder; mod swap_encoder; pub mod tycho_encoder; diff --git a/src/encoding/strategy_encoder.rs b/src/encoding/strategy_encoder.rs index 94e4e19..04d23e7 100644 --- a/src/encoding/strategy_encoder.rs +++ b/src/encoding/strategy_encoder.rs @@ -1,6 +1,6 @@ use tycho_core::{models::Chain, Bytes}; -use crate::encoding::{errors::EncodingError, models::Solution}; +use crate::encoding::{errors::EncodingError, models::Solution, swap_encoder::SwapEncoder}; pub trait StrategyEncoder { fn encode_strategy( @@ -8,13 +8,19 @@ pub trait StrategyEncoder { to_encode: Solution, router_address: Bytes, ) -> Result<(Vec, Bytes), EncodingError>; + + #[allow(clippy::borrowed_box)] + fn get_swap_encoder(&self, protocol_system: &str) -> Option<&Box>; } -pub trait StrategySelector { - fn select_strategy( - &self, - solution: &Solution, +pub trait StrategyEncoderRegistry { + fn new( + chain: Chain, + executors_file_path: &str, signer_pk: Option, - chain_id: Chain, - ) -> Result, EncodingError>; + ) -> Result + where + Self: Sized; + #[allow(clippy::borrowed_box)] + fn get_encoder(&self, solution: &Solution) -> Result<&Box, EncodingError>; } diff --git a/src/encoding/swap_encoder.rs b/src/encoding/swap_encoder.rs index d350f1e..4247de5 100644 --- a/src/encoding/swap_encoder.rs +++ b/src/encoding/swap_encoder.rs @@ -2,7 +2,6 @@ use crate::encoding::{ errors::EncodingError, models::{EncodingContext, Swap}, }; -#[allow(dead_code)] pub trait SwapEncoder: Sync + Send { fn new(executor_address: String) -> Self where @@ -14,4 +13,14 @@ pub trait SwapEncoder: Sync + Send { ) -> Result, EncodingError>; fn executor_address(&self) -> &str; fn executor_selector(&self) -> &str; + + /// Clones the swap encoder as a trait object. + /// This allows the encoder to be cloned when it is being used as a `Box`. + fn clone_box(&self) -> Box; +} + +impl Clone for Box { + fn clone(&self) -> Box { + self.clone_box() + } } diff --git a/src/encoding/tycho_encoder.rs b/src/encoding/tycho_encoder.rs index 42d92f6..8ee054e 100644 --- a/src/encoding/tycho_encoder.rs +++ b/src/encoding/tycho_encoder.rs @@ -1,10 +1,10 @@ use crate::encoding::{ errors::EncodingError, models::{Solution, Transaction}, - strategy_encoder::StrategySelector, + strategy_encoder::StrategyEncoderRegistry, }; -pub trait TychoEncoder { +pub trait TychoEncoder { fn encode_router_calldata( &self, solutions: Vec, From c89f46a2e697bc0ab6cd2ef13199593a3b4f02b1 Mon Sep 17 00:00:00 2001 From: Diana Carvalho Date: Tue, 4 Feb 2025 16:57:44 +0000 Subject: [PATCH 2/6] chore: Rename registry -> swap_encoder_registry Took 14 minutes Took 8 seconds --- src/encoding/evm/strategy_encoder/strategy_encoder_registry.rs | 2 +- src/encoding/evm/strategy_encoder/strategy_encoders.rs | 2 +- src/encoding/evm/swap_encoder/mod.rs | 2 +- .../evm/swap_encoder/{registry.rs => swap_encoder_registry.rs} | 0 4 files changed, 3 insertions(+), 3 deletions(-) rename src/encoding/evm/swap_encoder/{registry.rs => swap_encoder_registry.rs} (100%) diff --git a/src/encoding/evm/strategy_encoder/strategy_encoder_registry.rs b/src/encoding/evm/strategy_encoder/strategy_encoder_registry.rs index cb11fa0..5554c9d 100644 --- a/src/encoding/evm/strategy_encoder/strategy_encoder_registry.rs +++ b/src/encoding/evm/strategy_encoder/strategy_encoder_registry.rs @@ -6,7 +6,7 @@ use crate::encoding::{ errors::EncodingError, evm::{ strategy_encoder::strategy_encoders::{ExecutorStrategyEncoder, SplitSwapStrategyEncoder}, - swap_encoder::registry::SwapEncoderRegistry, + swap_encoder::swap_encoder_registry::SwapEncoderRegistry, }, models::Solution, strategy_encoder::{StrategyEncoder, StrategyEncoderRegistry}, diff --git a/src/encoding/evm/strategy_encoder/strategy_encoders.rs b/src/encoding/evm/strategy_encoder/strategy_encoders.rs index d65d926..e5daa45 100644 --- a/src/encoding/evm/strategy_encoder/strategy_encoders.rs +++ b/src/encoding/evm/strategy_encoder/strategy_encoders.rs @@ -10,7 +10,7 @@ use crate::encoding::{ evm::{ approvals::permit2::Permit2, constants::WETH_ADDRESS, - swap_encoder::registry::SwapEncoderRegistry, + swap_encoder::swap_encoder_registry::SwapEncoderRegistry, utils::{biguint_to_u256, bytes_to_address, encode_input, percentage_to_uint24}, }, models::{EncodingContext, NativeAction, Solution}, diff --git a/src/encoding/evm/swap_encoder/mod.rs b/src/encoding/evm/swap_encoder/mod.rs index 8d5bb3a..b676999 100644 --- a/src/encoding/evm/swap_encoder/mod.rs +++ b/src/encoding/evm/swap_encoder/mod.rs @@ -1,3 +1,3 @@ mod builder; -pub mod registry; +pub mod swap_encoder_registry; mod swap_encoders; diff --git a/src/encoding/evm/swap_encoder/registry.rs b/src/encoding/evm/swap_encoder/swap_encoder_registry.rs similarity index 100% rename from src/encoding/evm/swap_encoder/registry.rs rename to src/encoding/evm/swap_encoder/swap_encoder_registry.rs From 79f513c76bc8781b3977cb017507f43d0bb99580 Mon Sep 17 00:00:00 2001 From: Diana Carvalho Date: Tue, 4 Feb 2025 17:32:14 +0000 Subject: [PATCH 3/6] chore: After rebase with master fixes Took 2 minutes --- .../evm/strategy_encoder/strategy_encoders.rs | 12 ++++++++---- src/encoding/evm/tycho_encoder.rs | 11 +++++------ 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/encoding/evm/strategy_encoder/strategy_encoders.rs b/src/encoding/evm/strategy_encoder/strategy_encoders.rs index e5daa45..62a873e 100644 --- a/src/encoding/evm/strategy_encoder/strategy_encoders.rs +++ b/src/encoding/evm/strategy_encoder/strategy_encoders.rs @@ -498,8 +498,10 @@ mod tests { token_out: dai.clone(), split: 0f64, }; - - let encoder = SplitSwapStrategyEncoder::new(private_key, Chain::Ethereum).unwrap(); + let swap_encoder_registry = get_swap_encoder_registry(); + let encoder = + SplitSwapStrategyEncoder::new(private_key, Chain::Ethereum, swap_encoder_registry) + .unwrap(); let solution = Solution { exact_out: false, given_token: NATIVE_ADDRESS.clone(), @@ -545,8 +547,10 @@ mod tests { token_out: WETH_ADDRESS.clone(), split: 0f64, }; - - let encoder = SplitSwapStrategyEncoder::new(private_key, Chain::Ethereum).unwrap(); + let swap_encoder_registry = get_swap_encoder_registry(); + let encoder = + SplitSwapStrategyEncoder::new(private_key, Chain::Ethereum, swap_encoder_registry) + .unwrap(); let solution = Solution { exact_out: false, given_token: dai, diff --git a/src/encoding/evm/tycho_encoder.rs b/src/encoding/evm/tycho_encoder.rs index 3e41208..1a93400 100644 --- a/src/encoding/evm/tycho_encoder.rs +++ b/src/encoding/evm/tycho_encoder.rs @@ -24,7 +24,7 @@ impl EVMTychoEncoder { } } -impl EVMTychoEncoder { +impl EVMTychoEncoder { fn validate_solution(&self, solution: &Solution) -> Result<(), EncodingError> { if solution.exact_out { return Err(EncodingError::FatalError( @@ -104,13 +104,12 @@ impl TychoEncoder for EVMTychoEncoder { #[cfg(test)] mod tests { - use tycho_core::models::Chain; - - use tycho_core::dto::ProtocolComponent; + use tycho_core::{dto::ProtocolComponent, models::Chain}; use super::*; - use crate::encoding::{strategy_encoder::StrategyEncoder, swap_encoder::SwapEncoder}; - use crate::encoding::{models::Swap, strategy_encoder::StrategyEncoder}; + use crate::encoding::{ + models::Swap, strategy_encoder::StrategyEncoder, swap_encoder::SwapEncoder, + }; struct MockStrategyRegistry { strategy: Box, From 6557ede64b536c3cbb35cbc5a125b5c5fd888637 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Tue, 4 Feb 2025 17:36:31 +0000 Subject: [PATCH 4/6] chore(release): 0.30.0 [skip ci] ## [0.30.0](https://github.com/propeller-heads/tycho-execution/compare/0.29.1...0.30.0) (2025-02-04) ### Features * Refactor Registries ([23875b8](https://github.com/propeller-heads/tycho-execution/commit/23875b8b02396690b3f028c7696ea5b95e17e40e)) --- CHANGELOG.md | 7 +++++++ Cargo.lock | 2 +- Cargo.toml | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 65c591d..45d38cc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## [0.30.0](https://github.com/propeller-heads/tycho-execution/compare/0.29.1...0.30.0) (2025-02-04) + + +### Features + +* Refactor Registries ([23875b8](https://github.com/propeller-heads/tycho-execution/commit/23875b8b02396690b3f028c7696ea5b95e17e40e)) + ## [0.29.1](https://github.com/propeller-heads/tycho-execution/compare/0.29.0...0.29.1) (2025-02-04) diff --git a/Cargo.lock b/Cargo.lock index ffee51a..e678f46 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4163,7 +4163,7 @@ dependencies = [ [[package]] name = "tycho-execution" -version = "0.29.1" +version = "0.30.0" dependencies = [ "alloy", "alloy-primitives", diff --git a/Cargo.toml b/Cargo.toml index e309038..d980b9f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tycho-execution" -version = "0.29.1" +version = "0.30.0" edition = "2021" [dependencies] From 576f89d24ca25ab37ae59b4db97cbff946d6da58 Mon Sep 17 00:00:00 2001 From: royvardhan Date: Tue, 4 Feb 2025 23:30:23 +0530 Subject: [PATCH 5/6] fix: deprecated signature --- Cargo.lock | 174 ++++++++++++++++++-------- Cargo.toml | 2 +- src/encoding/evm/approvals/permit2.rs | 5 +- 3 files changed, 123 insertions(+), 58 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e678f46..afd1688 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -47,9 +47,9 @@ checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" [[package]] name = "alloy" -version = "0.5.4" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea8ebf106e84a1c37f86244df7da0c7587e697b71a0d565cce079449b85ac6f8" +checksum = "bbcc41e8a11a4975b18ec6afba2cc48d591fa63336a4c526dacb50479a8d6b35" dependencies = [ "alloy-consensus", "alloy-core", @@ -82,20 +82,35 @@ dependencies = [ [[package]] name = "alloy-consensus" -version = "0.5.4" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41ed961a48297c732a5d97ee321aa8bb5009ecadbcb077d8bec90cb54e651629" +checksum = "f4138dc275554afa6f18c4217262ac9388790b2fc393c2dfe03c51d357abf013" dependencies = [ "alloy-eips", "alloy-primitives", "alloy-rlp", "alloy-serde", + "alloy-trie", "auto_impl", "c-kzg", "derive_more", "serde", ] +[[package]] +name = "alloy-consensus-any" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fa04e1882c31288ce1028fdf31b6ea94cfa9eafa2e497f903ded631c8c6a42c" +dependencies = [ + "alloy-consensus", + "alloy-eips", + "alloy-primitives", + "alloy-rlp", + "alloy-serde", + "serde", +] + [[package]] name = "alloy-core" version = "0.8.19" @@ -140,9 +155,9 @@ dependencies = [ [[package]] name = "alloy-eip7702" -version = "0.3.2" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64ffc577390ce50234e02d841214b3dc0bea6aaaae8e04bbf3cb82e9a45da9eb" +checksum = "cabf647eb4650c91a9d38cb6f972bb320009e7e9d61765fb688a86f1563b33e8" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -152,9 +167,9 @@ dependencies = [ [[package]] name = "alloy-eips" -version = "0.5.4" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b69e06cf9c37be824b9d26d6d101114fdde6af0c87de2828b414c05c4b3daa71" +checksum = "52dd5869ed09e399003e0e0ec6903d981b2a92e74c5d37e6b40890bad2517526" dependencies = [ "alloy-eip2930", "alloy-eip7702", @@ -170,12 +185,14 @@ dependencies = [ [[package]] name = "alloy-genesis" -version = "0.5.4" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dde15e14944a88bd6a57d325e9a49b75558746fe16aaccc79713ae50a6a9574c" +checksum = "e7d2a7fe5c1a9bd6793829ea21a636f30fc2b3f5d2e7418ba86d96e41dd1f460" dependencies = [ + "alloy-eips", "alloy-primitives", "alloy-serde", + "alloy-trie", "serde", ] @@ -193,29 +210,31 @@ dependencies = [ [[package]] name = "alloy-json-rpc" -version = "0.5.4" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af5979e0d5a7bf9c7eb79749121e8256e59021af611322aee56e77e20776b4b3" +checksum = "2008bedb8159a255b46b7c8614516eda06679ea82f620913679afbd8031fea72" dependencies = [ "alloy-primitives", "alloy-sol-types", "serde", "serde_json", - "thiserror 1.0.69", + "thiserror 2.0.11", "tracing", ] [[package]] name = "alloy-network" -version = "0.5.4" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "204237129086ce5dc17a58025e93739b01b45313841f98fa339eb1d780511e57" +checksum = "4556f01fe41d0677495df10a648ddcf7ce118b0e8aa9642a0e2b6dd1fb7259de" dependencies = [ "alloy-consensus", + "alloy-consensus-any", "alloy-eips", "alloy-json-rpc", "alloy-network-primitives", "alloy-primitives", + "alloy-rpc-types-any", "alloy-rpc-types-eth", "alloy-serde", "alloy-signer", @@ -223,14 +242,16 @@ dependencies = [ "async-trait", "auto_impl", "futures-utils-wasm", - "thiserror 1.0.69", + "serde", + "serde_json", + "thiserror 2.0.11", ] [[package]] name = "alloy-network-primitives" -version = "0.5.4" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "514f70ee2a953db21631cd817b13a1571474ec77ddc03d47616d5e8203489fde" +checksum = "f31c3c6b71340a1d076831823f09cb6e02de01de5c6630a9631bdb36f947ff80" dependencies = [ "alloy-consensus", "alloy-eips", @@ -268,9 +289,9 @@ dependencies = [ [[package]] name = "alloy-provider" -version = "0.5.4" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4814d141ede360bb6cd1b4b064f1aab9de391e7c4d0d4d50ac89ea4bc1e25fbd" +checksum = "5a22c4441b3ebe2d77fa9cf629ba68c3f713eb91779cff84275393db97eddd82" dependencies = [ "alloy-chains", "alloy-consensus", @@ -296,7 +317,7 @@ dependencies = [ "schnellru", "serde", "serde_json", - "thiserror 1.0.69", + "thiserror 2.0.11", "tokio", "tracing", "url", @@ -327,9 +348,9 @@ dependencies = [ [[package]] name = "alloy-rpc-client" -version = "0.5.4" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fc2bd1e7403463a5f2c61e955bcc9d3072b63aa177442b0f9aa6a6d22a941e3" +checksum = "d06a292b37e182e514903ede6e623b9de96420e8109ce300da288a96d88b7e4b" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -350,9 +371,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types" -version = "0.5.4" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eea9bf1abdd506f985a53533f5ac01296bcd6102c5e139bbc5d40bc468d2c916" +checksum = "9383845dd924939e7ab0298bbfe231505e20928907d7905aa3bf112287305e06" dependencies = [ "alloy-primitives", "alloy-rpc-types-eth", @@ -361,29 +382,41 @@ dependencies = [ ] [[package]] -name = "alloy-rpc-types-eth" -version = "0.5.4" +name = "alloy-rpc-types-any" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00b034779a4850b4b03f5be5ea674a1cf7d746b2da762b34d1860ab45e48ca27" +checksum = "ca445cef0eb6c2cf51cfb4e214fbf1ebd00893ae2e6f3b944c8101b07990f988" +dependencies = [ + "alloy-consensus-any", + "alloy-rpc-types-eth", + "alloy-serde", +] + +[[package]] +name = "alloy-rpc-types-eth" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0938bc615c02421bd86c1733ca7205cc3d99a122d9f9bff05726bd604b76a5c2" dependencies = [ "alloy-consensus", + "alloy-consensus-any", "alloy-eips", "alloy-network-primitives", "alloy-primitives", "alloy-rlp", "alloy-serde", "alloy-sol-types", - "derive_more", "itertools 0.13.0", "serde", "serde_json", + "thiserror 2.0.11", ] [[package]] name = "alloy-serde" -version = "0.5.4" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "028e72eaa9703e4882344983cfe7636ce06d8cce104a78ea62fd19b46659efc4" +checksum = "ae0465c71d4dced7525f408d84873aeebb71faf807d22d74c4a426430ccd9b55" dependencies = [ "alloy-primitives", "serde", @@ -392,9 +425,9 @@ dependencies = [ [[package]] name = "alloy-signer" -version = "0.5.4" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "592c185d7100258c041afac51877660c7bf6213447999787197db4842f0e938e" +checksum = "9bfa395ad5cc952c82358d31e4c68b27bf4a89a5456d9b27e226e77dac50e4ff" dependencies = [ "alloy-dyn-abi", "alloy-primitives", @@ -403,14 +436,14 @@ dependencies = [ "auto_impl", "elliptic-curve", "k256", - "thiserror 1.0.69", + "thiserror 2.0.11", ] [[package]] name = "alloy-signer-aws" -version = "0.5.4" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a406102908a4e51834f32c4e5c1b29aa2c407b3fd23a5cad129c28b56d85e1b8" +checksum = "0eb06810c34427d499863817eb506acf57cb9ded9224b374116cae4e22dbd4e9" dependencies = [ "alloy-consensus", "alloy-network", @@ -420,15 +453,15 @@ dependencies = [ "aws-sdk-kms", "k256", "spki", - "thiserror 1.0.69", + "thiserror 2.0.11", "tracing", ] [[package]] name = "alloy-signer-gcp" -version = "0.5.4" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8d363e12280cb43747d3b62a1e6f00d595bc1a56464bb20200c6b6ca5d68185" +checksum = "d629e63fec8802ad53706d46e8eceeeae2b135c6648d0de41669a523bf17df4a" dependencies = [ "alloy-consensus", "alloy-network", @@ -438,15 +471,15 @@ dependencies = [ "gcloud-sdk", "k256", "spki", - "thiserror 1.0.69", + "thiserror 2.0.11", "tracing", ] [[package]] name = "alloy-signer-ledger" -version = "0.5.4" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59a642c9f66ac73ae0d5398ce7ce3ce5bdfad5658d549abd48ea48962e585dca" +checksum = "b426789566a19252cb46b757d91543a6f8e70330c72f312b86c5878595d092ef" dependencies = [ "alloy-consensus", "alloy-dyn-abi", @@ -458,15 +491,15 @@ dependencies = [ "coins-ledger", "futures-util", "semver 1.0.24", - "thiserror 1.0.69", + "thiserror 2.0.11", "tracing", ] [[package]] name = "alloy-signer-local" -version = "0.5.4" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6614f02fc1d5b079b2a4a5320018317b506fd0a6d67c1fd5542a71201724986c" +checksum = "fbdc63ce9eda1283fcbaca66ba4a414b841c0e3edbeef9c86a71242fc9e84ccc" dependencies = [ "alloy-consensus", "alloy-network", @@ -475,7 +508,7 @@ dependencies = [ "async-trait", "k256", "rand", - "thiserror 1.0.69", + "thiserror 2.0.11", ] [[package]] @@ -550,9 +583,9 @@ dependencies = [ [[package]] name = "alloy-transport" -version = "0.5.4" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be77579633ebbc1266ae6fd7694f75c408beb1aeb6865d0b18f22893c265a061" +checksum = "d17722a198f33bbd25337660787aea8b8f57814febb7c746bc30407bdfc39448" dependencies = [ "alloy-json-rpc", "base64 0.22.1", @@ -560,7 +593,7 @@ dependencies = [ "futures-utils-wasm", "serde", "serde_json", - "thiserror 1.0.69", + "thiserror 2.0.11", "tokio", "tower 0.5.2", "tracing", @@ -570,9 +603,9 @@ dependencies = [ [[package]] name = "alloy-transport-http" -version = "0.5.4" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91fd1a5d0827939847983b46f2f79510361f901dc82f8e3c38ac7397af142c6e" +checksum = "6e1509599021330a31c4a6816b655e34bf67acb1cc03c564e09fd8754ff6c5de" dependencies = [ "alloy-json-rpc", "alloy-transport", @@ -583,6 +616,22 @@ dependencies = [ "url", ] +[[package]] +name = "alloy-trie" +version = "0.7.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6917c79e837aa7b77b7a6dae9f89cbe15313ac161c4d3cfaf8909ef21f3d22d8" +dependencies = [ + "alloy-primitives", + "alloy-rlp", + "arrayvec", + "derive_more", + "nybbles", + "serde", + "smallvec", + "tracing", +] + [[package]] name = "android-tzdata" version = "0.1.1" @@ -733,6 +782,9 @@ name = "arrayvec" version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" +dependencies = [ + "serde", +] [[package]] name = "async-compression" @@ -2590,6 +2642,19 @@ dependencies = [ "syn 2.0.96", ] +[[package]] +name = "nybbles" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8983bb634df7248924ee0c4c3a749609b5abcb082c28fffe3254b3eb3602b307" +dependencies = [ + "alloy-rlp", + "const-hex", + "proptest", + "serde", + "smallvec", +] + [[package]] name = "object" version = "0.36.7" @@ -3644,6 +3709,9 @@ name = "smallvec" version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" +dependencies = [ + "serde", +] [[package]] name = "socket2" @@ -4470,9 +4538,9 @@ dependencies = [ [[package]] name = "wasmtimer" -version = "0.2.1" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7ed9d8b15c7fb594d72bfb4b5a276f3d2029333cd93a932f376f5937f6f80ee" +checksum = "0048ad49a55b9deb3953841fa1fc5858f0efbcb7a18868c899a360269fac1b23" dependencies = [ "futures", "js-sys", diff --git a/Cargo.toml b/Cargo.toml index d980b9f..53bda10 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,7 +15,7 @@ thiserror = "1.0.69" tokio = { version = "1.38.0", features = ["full"] } chrono = "0.4.39" -alloy = { version = "0.5.4", features = ["providers", "rpc-types-eth", "eip712", "signer-local"], optional = true } +alloy = { version = "0.9.2", features = ["providers", "rpc-types-eth", "eip712", "signer-local"], optional = true } alloy-sol-types = { version = "0.8.14", optional = true } alloy-primitives = { version = "0.8.9", optional = true } tycho-core = { git = "https://github.com/propeller-heads/tycho-indexer.git", package = "tycho-core", tag = "0.46.0" } diff --git a/src/encoding/evm/approvals/permit2.rs b/src/encoding/evm/approvals/permit2.rs index 1423ce0..7460cae 100644 --- a/src/encoding/evm/approvals/permit2.rs +++ b/src/encoding/evm/approvals/permit2.rs @@ -7,9 +7,7 @@ use alloy::{ signers::{local::PrivateKeySigner, SignerSync}, transports::BoxTransport, }; -#[allow(deprecated)] -use alloy_primitives::Signature; -use alloy_primitives::B256; +use alloy_primitives::{PrimitiveSignature as Signature, B256}; use alloy_sol_types::{eip712_domain, sol, SolStruct, SolValue}; use chrono::Utc; use num_bigint::BigUint; @@ -117,7 +115,6 @@ impl Permit2 { } } /// Creates permit single and signature - #[allow(deprecated)] pub fn get_permit( &self, spender: &Bytes, From 25a26f21be8949a6f4ca548fd8c9d908ad5285f4 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Tue, 4 Feb 2025 18:17:33 +0000 Subject: [PATCH 6/6] chore(release): 0.30.1 [skip ci] ## [0.30.1](https://github.com/propeller-heads/tycho-execution/compare/0.30.0...0.30.1) (2025-02-04) ### Bug Fixes * deprecated signature ([576f89d](https://github.com/propeller-heads/tycho-execution/commit/576f89d24ca25ab37ae59b4db97cbff946d6da58)) --- CHANGELOG.md | 7 +++++++ Cargo.lock | 2 +- Cargo.toml | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 45d38cc..960b704 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## [0.30.1](https://github.com/propeller-heads/tycho-execution/compare/0.30.0...0.30.1) (2025-02-04) + + +### Bug Fixes + +* deprecated signature ([576f89d](https://github.com/propeller-heads/tycho-execution/commit/576f89d24ca25ab37ae59b4db97cbff946d6da58)) + ## [0.30.0](https://github.com/propeller-heads/tycho-execution/compare/0.29.1...0.30.0) (2025-02-04) diff --git a/Cargo.lock b/Cargo.lock index afd1688..e35c23e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4231,7 +4231,7 @@ dependencies = [ [[package]] name = "tycho-execution" -version = "0.30.0" +version = "0.30.1" dependencies = [ "alloy", "alloy-primitives", diff --git a/Cargo.toml b/Cargo.toml index 53bda10..1c7e8f7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tycho-execution" -version = "0.30.0" +version = "0.30.1" edition = "2021" [dependencies]