diff --git a/examples/price_printer/main.rs b/examples/price_printer/main.rs index 1849e1d8..3c38d174 100644 --- a/examples/price_printer/main.rs +++ b/examples/price_printer/main.rs @@ -75,6 +75,7 @@ async fn main() { Some(uniswap_v4_pool_with_hook_filter), ) .auth_key(Some(tycho_api_key.clone())) + .skip_state_decode_failures(true) .set_tokens(all_tokens) .await .build() diff --git a/examples/price_printer/ui.rs b/examples/price_printer/ui.rs index 91e29e4d..df2a2278 100644 --- a/examples/price_printer/ui.rs +++ b/examples/price_printer/ui.rs @@ -16,6 +16,7 @@ use ratatui::{ DefaultTerminal, Frame, }; use tokio::{select, sync::mpsc::Receiver}; +use tracing::warn; use tycho_core::Bytes; use tycho_simulation::protocol::{ models::{BlockUpdate, ProtocolComponent}, @@ -151,17 +152,20 @@ impl App { .map(|el| el.spot_price(&comp.tokens[0], &comp.tokens[1])) .unwrap_or(Ok(0.0)); - self.items.push(Data { - component: comp.clone(), - state: update - .states - .get(id) - .unwrap_or_else(|| panic!("Received update for unknown pool {}", comp.address)) - .clone(), - name, - tokens, - price: format!("{}", price.expect("Expected f64 as spot price")), - }); + match update.states.get(id) { + Some(state) => { + self.items.push(Data { + component: comp.clone(), + state: state.clone(), + name, + tokens, + price: format!("{}", price.expect("Expected f64 as spot price")), + }); + } + None => { + warn!("Received update for unknown pool {}", comp.address) + } + }; } for (address, state) in update.states.iter() { diff --git a/examples/quickstart/main.rs b/examples/quickstart/main.rs index 7994bac2..f2d50a74 100644 --- a/examples/quickstart/main.rs +++ b/examples/quickstart/main.rs @@ -52,6 +52,7 @@ async fn main() { Some(uniswap_v4_pool_with_hook_filter), ) .auth_key(Some(tycho_api_key.clone())) + .skip_state_decode_failures(true) .set_tokens(all_tokens.clone()) .await .build() diff --git a/src/evm/decoder.rs b/src/evm/decoder.rs index 12b4cc1e..dbea83b0 100644 --- a/src/evm/decoder.rs +++ b/src/evm/decoder.rs @@ -9,7 +9,7 @@ use std::{ use alloy_primitives::Address; use thiserror::Error; use tokio::sync::RwLock; -use tracing::{debug, info, warn}; +use tracing::{debug, error, info, warn}; use tycho_client::feed::{synchronizer::ComponentWithState, FeedMessage, Header}; use tycho_core::Bytes; @@ -233,7 +233,7 @@ impl TychoStreamDecoder { .iter() .map(|(key, value)| (Address::from_slice(&key[..20]), value.clone().into())) .collect(); - info!("Updating engine with snapshot"); + info!("Updating engine with {} snapshots", storage_by_address.len()); update_engine( SHARED_TYCHO_DB.clone(), block.clone().into(), @@ -241,7 +241,7 @@ impl TychoStreamDecoder { HashMap::new(), ) .await; - info!("Engine updated with snapshot"); + info!("Engine updated"); let mut new_components = HashMap::new(); @@ -288,6 +288,7 @@ impl TychoStreamDecoder { warn!(pool = id, error = %e, "StateDecodingFailure"); continue 'outer; } else { + error!(pool = id, error = %e, "StateDecodingFailure"); return Err(StreamDecodeError::Fatal(format!("{e}"))); } } @@ -296,6 +297,7 @@ impl TychoStreamDecoder { warn!(pool = id, "MissingDecoderRegistration"); continue 'outer; } else { + error!(pool = id, "MissingDecoderRegistration"); return Err(StreamDecodeError::Fatal(format!( "Missing decoder registration for: {id}" ))); @@ -303,7 +305,7 @@ impl TychoStreamDecoder { } if !new_components.is_empty() { - debug!("Decoded {} snapshots for protocol {}", new_components.len(), protocol); + info!("Decoded {} snapshots for protocol {}", new_components.len(), protocol); } updated_states.extend(new_components); @@ -315,7 +317,7 @@ impl TychoStreamDecoder { .iter() .map(|(key, value)| (Address::from_slice(&key[..20]), value.clone().into())) .collect(); - info!("Updating engine with deltas"); + info!("Updating engine with {} deltas", deltas.state_updates.len()); update_engine( SHARED_TYCHO_DB.clone(), block.clone().into(), @@ -323,7 +325,7 @@ impl TychoStreamDecoder { account_update_by_address, ) .await; - info!("Engine updated with deltas"); + info!("Engine updated"); for (id, update) in deltas.state_updates { match updated_states.entry(id.clone()) { @@ -333,6 +335,7 @@ impl TychoStreamDecoder { state .delta_transition(update, &state_guard.tokens) .map_err(|e| { + error!(pool = id, error = ?e, "DeltaTransitionError"); StreamDecodeError::Fatal(format!("TransitionFailure: {e:?}")) })?; } @@ -345,6 +348,7 @@ impl TychoStreamDecoder { state .delta_transition(update, &state_guard.tokens) .map_err(|e| { + error!(pool = id, error = ?e, "DeltaTransitionError"); StreamDecodeError::Fatal(format!( "TransitionFailure: {e:?}" ))