From 1e58f5c1fe75378413a6c7c2560bdf1b0a0f28aa Mon Sep 17 00:00:00 2001 From: Mike Rolish Date: Wed, 16 Apr 2025 09:31:07 -0500 Subject: [PATCH 1/2] chore: cargo update, zero price handling --- Cargo.lock | 8 ++++---- src/agent/services/lazer_exporter.rs | 16 +++++++++++++--- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 616099f..f6dedc9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3527,9 +3527,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.94" +version = "1.0.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a31971752e70b8b2686d7e46ec17fb38dad4051d94024c88df49b667caea9c84" +checksum = "02b3e5e68a3a1a02aad3ec490a98007cbc13c37cbe84a3cd7b8e406d76e7f778" dependencies = [ "unicode-ident", ] @@ -6188,9 +6188,9 @@ dependencies = [ [[package]] name = "solana-vote-interface" -version = "2.2.3" +version = "2.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b630547b7f12ee742e1c5069951fedba0fe5cbd4786f6342a779384e2b11f71" +checksum = "78f039b0788337bedc6c5450d2f237718f938defb5ce0e0ad8ef507e78dcd370" dependencies = [ "bincode 1.3.3", "num-derive 0.4.2", diff --git a/src/agent/services/lazer_exporter.rs b/src/agent/services/lazer_exporter.rs index 6bd687e..dcef967 100644 --- a/src/agent/services/lazer_exporter.rs +++ b/src/agent/services/lazer_exporter.rs @@ -1,6 +1,9 @@ use { crate::agent::state, - anyhow::Result, + anyhow::{ + anyhow, + Result, + }, futures_util::{ stream::{ SplitSink, @@ -135,7 +138,7 @@ struct SymbolResponse { async fn fetch_symbols(history_url: &Url) -> Result> { let mut url = history_url.clone(); - url.set_scheme("http").unwrap(); + url.set_scheme("http").map_err(|_| anyhow!("invalid url"))?; url.set_path("/history/v1/symbols"); let client = Client::new(); let response = client.get(url).send().await?.error_for_status()?; @@ -181,6 +184,7 @@ mod lazer_exporter { time::Duration, }, tokio_stream::StreamMap, + tracing::warn, }; pub async fn lazer_exporter(config: Config, state: Arc) @@ -245,8 +249,14 @@ mod lazer_exporter { // TODO: This read locks and clones local::Store::prices, which may not meet performance needs. for (identifier, price_info) in state.get_all_price_infos().await { if let Some(symbol) = lazer_symbols.get(&identifier.to_string()) { + let price = if let Ok(price) = NonZeroI64::try_from(price_info.price) { + Some(Price(price)) + } else { + warn!("Zero price in local state identifier: {identifier} price_info: {price_info:?}"); + continue; + }; if let Err(e) = relayer_sender.send_price_update(&PriceFeedDataV1 { - price: Some(Price(NonZeroI64::try_from(price_info.price).unwrap())), + price, best_ask_price: None, best_bid_price: None, price_feed_id: PriceFeedId(symbol.pyth_lazer_id), From 88dceb9bf30b57b94d9b69ceabd75051254c4ae8 Mon Sep 17 00:00:00 2001 From: Mike Rolish Date: Wed, 16 Apr 2025 11:01:51 -0500 Subject: [PATCH 2/2] bump pre-commit/action to 3.0.1 --- .github/workflows/rustfmt.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/rustfmt.yaml b/.github/workflows/rustfmt.yaml index 551757d..08318f0 100644 --- a/.github/workflows/rustfmt.yaml +++ b/.github/workflows/rustfmt.yaml @@ -16,4 +16,4 @@ jobs: profile: minimal toolchain: nightly components: rustfmt - - uses: pre-commit/action@v2.0.3 + - uses: pre-commit/action@v3.0.1