feat: update tycho deps and upgrade code

This commit is contained in:
adrian
2025-09-02 11:04:24 +02:00
committed by Tamara
parent f7e3b7350e
commit f3500dff44
6 changed files with 2110 additions and 1506 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -7,11 +7,11 @@ edition = "2021"
# Logging & Tracing
tracing = "0.1.37"
# Tycho dependencies
tycho-common = "0.66.4"
tycho-client = "0.66.4"
tycho-common = "0.83.0"
tycho-client = "0.83.0"
tycho-simulation = { path = "../../tycho-simulation", features = ["evm"] }
# EVM dependencies
alloy = { version = "0.5.4", features = ["arbitrary", "json", "dyn-abi", "sol-types", "contract", "provider-http"] }
alloy = { version = "1.0.27", features = ["arbitrary", "json", "dyn-abi", "sol-types", "contract", "provider-http"] }
tokio = { version = "1", features = ["full"] }
serde_json = "1.0.140"
clap = "4.5.31"

View File

@@ -31,7 +31,7 @@ impl RPCProvider {
wallet_address: Address,
block_number: u64,
) -> U256 {
let provider = ProviderBuilder::new().on_http(self.url.clone());
let provider = ProviderBuilder::new().connect_http(self.url.clone());
let block_id: BlockId = BlockId::from(block_number);
match NATIVE_ALIASES.contains(&token_address) {
@@ -65,13 +65,13 @@ impl RPCProvider {
}
}
async fn get_block_header(&self, block_number: u64) {
// TODO: Implement
// let provider = ProviderBuilder::new().on_http(self.url);
// let block_id: BlockId = BlockId::from(block_number);
//
// let block = provider.get_block(block_id)
}
// TODO: Implement
// async fn get_block_header(&self, _block_number: u64) {
// let provider = ProviderBuilder::new().on_http(self.url);
// let block_id: BlockId = BlockId::from(block_number);
//
// let block = provider.get_block(block_id)
// }
}
#[cfg(test)]

View File

@@ -1,6 +1,5 @@
use std::{collections::HashMap, env, path::PathBuf, str::FromStr};
use alloy::{primitives::U256, providers::Provider};
use alloy::{primitives::U256};
use figment::{
providers::{Format, Yaml},
Figment,
@@ -8,9 +7,11 @@ use figment::{
use postgres::{Client, Error, NoTls};
use tokio::runtime::Runtime;
use tracing::{debug, info};
use tycho_client::feed::BlockHeader;
use tycho_common::{
dto::{Chain, ProtocolComponent, ResponseAccount, ResponseProtocolState},
Bytes,
models::token::Token
};
use tycho_simulation::{
evm::{
@@ -18,12 +19,10 @@ use tycho_simulation::{
engine_db::tycho_db::PreCachedDB,
protocol::{u256_num::bytes_to_u256, vm::state::EVMPoolState},
},
models::Token,
tycho_client::feed::{
synchronizer::{ComponentWithState, Snapshot, StateSyncMessage},
FeedMessage, Header,
FeedMessage,
},
utils::load_all_tokens,
};
use crate::{
@@ -39,7 +38,6 @@ pub struct TestRunner {
tycho_logs: bool,
db_url: String,
vm_traces: bool,
substreams_path: PathBuf,
}
@@ -284,7 +282,7 @@ fn validate_state(
.get(component_id)
.expect("Failed to get state for component")
.clone();
let component_with_state = ComponentWithState { state, component };
let component_with_state = ComponentWithState { state, component, component_tvl: None, entrypoints: vec![] }; // TODO
states.insert(component_id.clone(), component_with_state);
}
let vm_storage: HashMap<Bytes, ResponseAccount> = vm_storages
@@ -295,14 +293,15 @@ fn validate_state(
let bytes = [0u8; 32];
let state_msgs: HashMap<String, StateSyncMessage> = HashMap::from([(
let state_msgs: HashMap<String, StateSyncMessage<BlockHeader>> = HashMap::from([(
String::from("test_protocol"),
StateSyncMessage {
header: Header {
header: BlockHeader {
hash: Bytes::from(bytes),
number: stop_block,
parent_hash: Bytes::from(bytes),
revert: false,
timestamp: 0, // TODO
},
snapshots: snapshot,
deltas: None,

View File

@@ -1,17 +1,17 @@
use tycho_client::rpc::RPCClient;
use std::{collections::HashMap, error::Error as StdError, fmt};
use tracing::info;
use tycho_client::{rpc::RPCClient, HttpRPCClient};
use tycho_client::{HttpRPCClient};
use tycho_common::{
dto::{
Chain, PaginationParams, ProtocolComponent, ProtocolComponentsRequestBody, ResponseAccount,
ResponseProtocolState, StateRequestBody, VersionParam,
},
models::Address,
Bytes,
};
use tycho_common::dto::ResponseToken;
use tycho_simulation::models::Token;
use tycho_common::models::token::Token;
/// Custom error type for RPC operations
#[derive(Debug)]

View File

@@ -29,7 +29,7 @@ impl TychoRunner {
spkg_path: &str,
start_block: u64,
end_block: u64,
protocol_type_names: &Vec<String>,
protocol_type_names: &[String],
) -> Result<(), Box<dyn std::error::Error>> {
// Expects a .env present in the same folder as package root (where Cargo.toml is)
dotenv().ok();
@@ -160,7 +160,7 @@ impl TychoRunner {
if let Some(stdout) = child.stdout.take() {
thread::spawn(move || {
let reader = BufReader::new(stdout);
for line in reader.lines().flatten() {
for line in reader.lines().map_while(Result::ok) {
println!("{}", line);
}
});
@@ -169,7 +169,7 @@ impl TychoRunner {
if let Some(stderr) = child.stderr.take() {
thread::spawn(move || {
let reader = BufReader::new(stderr);
for line in reader.lines().flatten() {
for line in reader.lines().map_while(Result::ok) {
eprintln!("{}", line);
}
});