Skip to content

chore: Bump Rust edition and Solana crates #159

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3,363 changes: 2,141 additions & 1,222 deletions Cargo.lock

Large diffs are not rendered by default.

44 changes: 16 additions & 28 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
[package]
name = "pyth-agent"
version = "2.12.3"
edition = "2021"
edition = "2024"

[[bin]]
name = "agent"
path = "src/bin/agent.rs"

[dependencies]
anyhow = "1.0.81"
ed25519-dalek = "1.0.1"
serde = { version = "1.0.197", features = ["derive"] }
ed25519-dalek = "2.1.1"
serde = { version = "1.0.197", features = ["derive", "rc"] }
async-trait = "0.1.79"
warp = { version = "0.3.6", features = ["websocket"] }
tokio = { version = "1.37.0", features = ["full"] }
Expand All @@ -22,35 +22,31 @@ futures-util = { version = "0.3.30", default-features = false, features = [
jrpc = "0.4.1"
serde_json = "1.0.115"
chrono = "0.4.37"
chrono-tz = "0.8.6"
parking_lot = "0.12.1"
chrono-tz = "0.10.3"
pyth-sdk = "0.8.0"
pyth-sdk-solana = "0.10.4"
solana-account-decoder = "1.18.8"
solana-client = "1.18.8"
solana-pubkey = "2.3.0"
solana-sdk = "1.18.8"
solana-transaction-status = "1.18.26"
solana-account-decoder = "2.2.1"
solana-client = "2.2.1"
solana-pubkey = "2.2.1"
solana-sdk = "2.2.1"
solana-transaction-status = "2.2.1"
bincode = { version = "2.0.1", features = ["serde"] }
rand = "0.8.5"
config = "0.14.0"
thiserror = "1.0.58"
config = "0.15.11"
thiserror = "2.0.12"
clap = { version = "4.5.4", features = ["derive"] }
humantime-serde = "1.1.1"
serde-this-or-that = "0.4.2"
humantime = "2.1.0"
prometheus-client = "0.22.2"
serde-this-or-that = "0.5.0"
prometheus-client = "0.23.1"
lazy_static = "1.4.0"
toml_edit = "0.22.9"
winnow = "0.6.5"
winnow = "0.7.7"
proptest = "1.4.0"
reqwest = { version = "0.12.0", features = ["json"] }
smol_str = {version="0.3.2", features=["serde"]}
smol_str = { version="0.3.2", features=["serde"] }
tracing = { version = "0.1.40", features = ["log"] }
tracing-subscriber = { version = "0.3.18", features = ["env-filter", "json"] }
tracing-opentelemetry = "0.24.0"
opentelemetry = "0.23.0"
opentelemetry_sdk = { version = "0.23.0", features = ["rt-tokio"]}
opentelemetry_sdk = { version = "0.23.0", features = ["rt-tokio"] }
opentelemetry-otlp = { version = "0.16.0" }
protobuf = "3.7.2"
pyth-price-store = "0.1.0"
Expand All @@ -59,14 +55,6 @@ tokio-tungstenite = { version = "0.26.2", features = ["native-tls", "url"] }
http = "1.3.1"
url = { version = "2.5.4", features = ["serde"] }
pyth-lazer-publisher-sdk = "0.1.1"
tokio-util = { version = "0.7.14", features = ["full"] }

[dev-dependencies]
soketto = "0.8.0"
portpicker = "0.1.1"
rand = "0.8.5"
tokio-retry = "0.3.0"
iobuffer = "0.2.0"

[profile.release]
panic = 'abort'
Expand Down
11 changes: 7 additions & 4 deletions src/agent/legacy_schedule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,22 @@

use {
anyhow::{
anyhow,
Context,
Result,
anyhow,
},
chrono::{
naive::NaiveTime,
DateTime,
Datelike,
Duration,
Utc,
Weekday,
naive::NaiveTime,
},
chrono_tz::{
ParseError,
Tz,
},
chrono_tz::Tz,
lazy_static::lazy_static,
std::str::FromStr,
};
Expand Down Expand Up @@ -89,7 +92,7 @@ impl FromStr for LegacySchedule {
let tz: Tz = tz_str
.trim()
.parse()
.map_err(|e: String| anyhow!(e))
.map_err(|e: ParseError| anyhow!(e))
.context(format!("Could parse timezone from {:?}", tz_str))?;

let mut weekday_schedules = Vec::with_capacity(7);
Expand Down
77 changes: 52 additions & 25 deletions src/agent/market_schedule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ use {
MHKind,
},
anyhow::{
anyhow,
Result,
anyhow,
},
chrono::{
naive::NaiveTime,
DateTime,
Datelike,
Duration,
Utc,
naive::NaiveTime,
},
chrono_tz::Tz,
std::{
Expand All @@ -24,6 +24,8 @@ use {
str::FromStr,
},
winnow::{
ModalResult,
Parser,
combinator::{
alt,
separated,
Expand All @@ -34,8 +36,6 @@ use {
take,
take_till,
},
ModalResult,
Parser,
},
};

Expand Down Expand Up @@ -109,7 +109,7 @@ impl MarketSchedule {
}
}

fn market_schedule_parser<'s>(input: &mut &'s str) -> ModalResult<MarketSchedule> {
fn market_schedule_parser(input: &mut &str) -> ModalResult<MarketSchedule> {
seq!(
MarketSchedule {
timezone: take_till(0.., ';').verify_map(|s| Tz::from_str(s).ok()),
Expand Down Expand Up @@ -157,13 +157,13 @@ pub struct HolidayDaySchedule {
pub kind: ScheduleDayKind,
}

fn two_digit_parser<'s>(input: &mut &'s str) -> ModalResult<u32> {
fn two_digit_parser(input: &mut &str) -> ModalResult<u32> {
take(2usize)
.verify_map(|s| u32::from_str(s).ok())
.parse_next(input)
}

fn holiday_day_schedule_parser<'s>(input: &mut &'s str) -> ModalResult<HolidayDaySchedule> {
fn holiday_day_schedule_parser(input: &mut &str) -> ModalResult<HolidayDaySchedule> {
// day and month are not validated to be correct dates
// if they are invalid, it will be ignored since there
// are no real dates that match the invalid input
Expand Down Expand Up @@ -454,40 +454,67 @@ mod tests {
let format = "%Y-%m-%d %H:%M";

// Date no match
assert!(market_schedule
.can_publish_at(&NaiveDateTime::parse_from_str("2023-11-20 05:30", format)?.and_utc()));
assert!(
market_schedule.can_publish_at(
&NaiveDateTime::parse_from_str("2023-11-20 05:30", format)?.and_utc()
)
);

// Date match before range
assert!(!market_schedule
.can_publish_at(&NaiveDateTime::parse_from_str("2023-04-22 08:59", format)?.and_utc()));
assert!(
!market_schedule.can_publish_at(
&NaiveDateTime::parse_from_str("2023-04-22 08:59", format)?.and_utc()
)
);

// Date match at start of range
assert!(market_schedule
.can_publish_at(&NaiveDateTime::parse_from_str("2023-04-22 09:00", format)?.and_utc()));
assert!(
market_schedule.can_publish_at(
&NaiveDateTime::parse_from_str("2023-04-22 09:00", format)?.and_utc()
)
);

// Date match in range
assert!(market_schedule
.can_publish_at(&NaiveDateTime::parse_from_str("2023-04-22 12:00", format)?.and_utc()));
assert!(
market_schedule.can_publish_at(
&NaiveDateTime::parse_from_str("2023-04-22 12:00", format)?.and_utc()
)
);

// Date match at end of range
assert!(market_schedule
.can_publish_at(&NaiveDateTime::parse_from_str("2023-04-22 17:00", format)?.and_utc()));
assert!(
market_schedule.can_publish_at(
&NaiveDateTime::parse_from_str("2023-04-22 17:00", format)?.and_utc()
)
);

// Date match after range
assert!(!market_schedule
.can_publish_at(&NaiveDateTime::parse_from_str("2023-04-22 17:01", format)?.and_utc()));
assert!(
!market_schedule.can_publish_at(
&NaiveDateTime::parse_from_str("2023-04-22 17:01", format)?.and_utc()
)
);

// Date 2400 range
assert!(market_schedule
.can_publish_at(&NaiveDateTime::parse_from_str("2023-12-31 23:59", format)?.and_utc()));
assert!(
market_schedule.can_publish_at(
&NaiveDateTime::parse_from_str("2023-12-31 23:59", format)?.and_utc()
)
);

// Sunday
assert!(market_schedule
.can_publish_at(&NaiveDateTime::parse_from_str("2024-04-14 12:00", format)?.and_utc()));
assert!(
market_schedule.can_publish_at(
&NaiveDateTime::parse_from_str("2024-04-14 12:00", format)?.and_utc()
)
);

// Monday
assert!(market_schedule
.can_publish_at(&NaiveDateTime::parse_from_str("2024-04-15 12:00", format)?.and_utc()));
assert!(
market_schedule.can_publish_at(
&NaiveDateTime::parse_from_str("2024-04-15 12:00", format)?.and_utc()
)
);

Ok(())
}
Expand Down
9 changes: 5 additions & 4 deletions src/agent/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use {
lazy_static::lazy_static,
prometheus_client::{
encoding::{
text::encode,
EncodeLabelSet,
text::encode,
},
metrics::{
counter::Counter,
Expand All @@ -20,17 +20,17 @@ use {
std::{
net::SocketAddr,
sync::{
atomic::AtomicU64,
Arc,
atomic::AtomicU64,
},
},
tokio::sync::Mutex,
warp::{
hyper::StatusCode,
reply,
Filter,
Rejection,
Reply,
hyper::StatusCode,
reply,
},
};

Expand Down Expand Up @@ -63,6 +63,7 @@ pub async fn spawn(addr: impl Into<SocketAddr> + 'static) {
.and(warp::path::end())
.and_then(move || async move {
let mut buf = String::new();
#[allow(clippy::needless_borrow)]
let response = encode(&mut buf, &&PROMETHEUS_REGISTRY.lock().await)
.map_err(|e| -> Box<dyn std::error::Error> { e.into() })
.map(|_| Box::new(reply::with_status(buf, StatusCode::OK)))
Expand Down
10 changes: 5 additions & 5 deletions src/agent/pyth/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,31 +15,31 @@ use {
},
crate::agent::state,
anyhow::{
anyhow,
Result,
anyhow,
},
futures::future::OptionFuture,
futures_util::{
SinkExt,
stream::{
SplitSink,
SplitStream,
StreamExt,
},
SinkExt,
},
jrpc::{
parse_request,
ErrorCode,
Id,
IdReq,
Request,
Response,
Value,
parse_request,
},
serde::{
de::DeserializeOwned,
Deserialize,
Serialize,
de::DeserializeOwned,
},
serde_this_or_that::{
as_i64,
Expand All @@ -57,12 +57,12 @@ use {
},
tracing::instrument,
warp::{
Filter,
ws::{
Message,
WebSocket,
Ws,
},
Filter,
},
};

Expand Down
2 changes: 1 addition & 1 deletion src/agent/pyth/rpc/get_product.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use {
},
crate::agent::state,
anyhow::{
anyhow,
Result,
anyhow,
},
jrpc::{
Request,
Expand Down
2 changes: 1 addition & 1 deletion src/agent/pyth/rpc/subscribe_price.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ use {
},
crate::agent::state,
anyhow::{
anyhow,
Result,
anyhow,
},
jrpc::{
Request,
Expand Down
2 changes: 1 addition & 1 deletion src/agent/pyth/rpc/subscribe_price_sched.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ use {
},
crate::agent::state,
anyhow::{
anyhow,
Result,
anyhow,
},
jrpc::{
Request,
Expand Down
2 changes: 1 addition & 1 deletion src/agent/pyth/rpc/update_price.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use {
},
crate::agent::state,
anyhow::{
anyhow,
Result,
anyhow,
},
jrpc::{
Request,
Expand Down
Loading
Loading