Skip to content

Commit 4ffe002

Browse files
authored
chore: Bump Rust edition and Solana crates (#159)
1 parent af91c2f commit 4ffe002

22 files changed

+2294
-1351
lines changed

Cargo.lock

Lines changed: 2141 additions & 1222 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 16 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
[package]
22
name = "pyth-agent"
33
version = "2.12.3"
4-
edition = "2021"
4+
edition = "2024"
55

66
[[bin]]
77
name = "agent"
88
path = "src/bin/agent.rs"
99

1010
[dependencies]
1111
anyhow = "1.0.81"
12-
ed25519-dalek = "1.0.1"
13-
serde = { version = "1.0.197", features = ["derive"] }
12+
ed25519-dalek = "2.1.1"
13+
serde = { version = "1.0.197", features = ["derive", "rc"] }
1414
async-trait = "0.1.79"
1515
warp = { version = "0.3.6", features = ["websocket"] }
1616
tokio = { version = "1.37.0", features = ["full"] }
@@ -22,35 +22,31 @@ futures-util = { version = "0.3.30", default-features = false, features = [
2222
jrpc = "0.4.1"
2323
serde_json = "1.0.115"
2424
chrono = "0.4.37"
25-
chrono-tz = "0.8.6"
26-
parking_lot = "0.12.1"
25+
chrono-tz = "0.10.3"
2726
pyth-sdk = "0.8.0"
2827
pyth-sdk-solana = "0.10.4"
29-
solana-account-decoder = "1.18.8"
30-
solana-client = "1.18.8"
31-
solana-pubkey = "2.3.0"
32-
solana-sdk = "1.18.8"
33-
solana-transaction-status = "1.18.26"
28+
solana-account-decoder = "2.2.1"
29+
solana-client = "2.2.1"
30+
solana-pubkey = "2.2.1"
31+
solana-sdk = "2.2.1"
32+
solana-transaction-status = "2.2.1"
3433
bincode = { version = "2.0.1", features = ["serde"] }
35-
rand = "0.8.5"
36-
config = "0.14.0"
37-
thiserror = "1.0.58"
34+
config = "0.15.11"
35+
thiserror = "2.0.12"
3836
clap = { version = "4.5.4", features = ["derive"] }
3937
humantime-serde = "1.1.1"
40-
serde-this-or-that = "0.4.2"
41-
humantime = "2.1.0"
42-
prometheus-client = "0.22.2"
38+
serde-this-or-that = "0.5.0"
39+
prometheus-client = "0.23.1"
4340
lazy_static = "1.4.0"
44-
toml_edit = "0.22.9"
45-
winnow = "0.6.5"
41+
winnow = "0.7.7"
4642
proptest = "1.4.0"
4743
reqwest = { version = "0.12.0", features = ["json"] }
48-
smol_str = {version="0.3.2", features=["serde"]}
44+
smol_str = { version="0.3.2", features=["serde"] }
4945
tracing = { version = "0.1.40", features = ["log"] }
5046
tracing-subscriber = { version = "0.3.18", features = ["env-filter", "json"] }
5147
tracing-opentelemetry = "0.24.0"
5248
opentelemetry = "0.23.0"
53-
opentelemetry_sdk = { version = "0.23.0", features = ["rt-tokio"]}
49+
opentelemetry_sdk = { version = "0.23.0", features = ["rt-tokio"] }
5450
opentelemetry-otlp = { version = "0.16.0" }
5551
protobuf = "3.7.2"
5652
pyth-price-store = "0.1.0"
@@ -59,14 +55,6 @@ tokio-tungstenite = { version = "0.26.2", features = ["native-tls", "url"] }
5955
http = "1.3.1"
6056
url = { version = "2.5.4", features = ["serde"] }
6157
pyth-lazer-publisher-sdk = "0.1.1"
62-
tokio-util = { version = "0.7.14", features = ["full"] }
63-
64-
[dev-dependencies]
65-
soketto = "0.8.0"
66-
portpicker = "0.1.1"
67-
rand = "0.8.5"
68-
tokio-retry = "0.3.0"
69-
iobuffer = "0.2.0"
7058

7159
[profile.release]
7260
panic = 'abort'

src/agent/legacy_schedule.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,22 @@
33

44
use {
55
anyhow::{
6-
anyhow,
76
Context,
87
Result,
8+
anyhow,
99
},
1010
chrono::{
11-
naive::NaiveTime,
1211
DateTime,
1312
Datelike,
1413
Duration,
1514
Utc,
1615
Weekday,
16+
naive::NaiveTime,
17+
},
18+
chrono_tz::{
19+
ParseError,
20+
Tz,
1721
},
18-
chrono_tz::Tz,
1922
lazy_static::lazy_static,
2023
std::str::FromStr,
2124
};
@@ -89,7 +92,7 @@ impl FromStr for LegacySchedule {
8992
let tz: Tz = tz_str
9093
.trim()
9194
.parse()
92-
.map_err(|e: String| anyhow!(e))
95+
.map_err(|e: ParseError| anyhow!(e))
9396
.context(format!("Could parse timezone from {:?}", tz_str))?;
9497

9598
let mut weekday_schedules = Vec::with_capacity(7);

src/agent/market_schedule.rs

Lines changed: 52 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ use {
77
MHKind,
88
},
99
anyhow::{
10-
anyhow,
1110
Result,
11+
anyhow,
1212
},
1313
chrono::{
14-
naive::NaiveTime,
1514
DateTime,
1615
Datelike,
1716
Duration,
1817
Utc,
18+
naive::NaiveTime,
1919
},
2020
chrono_tz::Tz,
2121
std::{
@@ -24,6 +24,8 @@ use {
2424
str::FromStr,
2525
},
2626
winnow::{
27+
ModalResult,
28+
Parser,
2729
combinator::{
2830
alt,
2931
separated,
@@ -34,8 +36,6 @@ use {
3436
take,
3537
take_till,
3638
},
37-
ModalResult,
38-
Parser,
3939
},
4040
};
4141

@@ -109,7 +109,7 @@ impl MarketSchedule {
109109
}
110110
}
111111

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

160-
fn two_digit_parser<'s>(input: &mut &'s str) -> ModalResult<u32> {
160+
fn two_digit_parser(input: &mut &str) -> ModalResult<u32> {
161161
take(2usize)
162162
.verify_map(|s| u32::from_str(s).ok())
163163
.parse_next(input)
164164
}
165165

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

456456
// Date no match
457-
assert!(market_schedule
458-
.can_publish_at(&NaiveDateTime::parse_from_str("2023-11-20 05:30", format)?.and_utc()));
457+
assert!(
458+
market_schedule.can_publish_at(
459+
&NaiveDateTime::parse_from_str("2023-11-20 05:30", format)?.and_utc()
460+
)
461+
);
459462

460463
// Date match before range
461-
assert!(!market_schedule
462-
.can_publish_at(&NaiveDateTime::parse_from_str("2023-04-22 08:59", format)?.and_utc()));
464+
assert!(
465+
!market_schedule.can_publish_at(
466+
&NaiveDateTime::parse_from_str("2023-04-22 08:59", format)?.and_utc()
467+
)
468+
);
463469

464470
// Date match at start of range
465-
assert!(market_schedule
466-
.can_publish_at(&NaiveDateTime::parse_from_str("2023-04-22 09:00", format)?.and_utc()));
471+
assert!(
472+
market_schedule.can_publish_at(
473+
&NaiveDateTime::parse_from_str("2023-04-22 09:00", format)?.and_utc()
474+
)
475+
);
467476

468477
// Date match in range
469-
assert!(market_schedule
470-
.can_publish_at(&NaiveDateTime::parse_from_str("2023-04-22 12:00", format)?.and_utc()));
478+
assert!(
479+
market_schedule.can_publish_at(
480+
&NaiveDateTime::parse_from_str("2023-04-22 12:00", format)?.and_utc()
481+
)
482+
);
471483

472484
// Date match at end of range
473-
assert!(market_schedule
474-
.can_publish_at(&NaiveDateTime::parse_from_str("2023-04-22 17:00", format)?.and_utc()));
485+
assert!(
486+
market_schedule.can_publish_at(
487+
&NaiveDateTime::parse_from_str("2023-04-22 17:00", format)?.and_utc()
488+
)
489+
);
475490

476491
// Date match after range
477-
assert!(!market_schedule
478-
.can_publish_at(&NaiveDateTime::parse_from_str("2023-04-22 17:01", format)?.and_utc()));
492+
assert!(
493+
!market_schedule.can_publish_at(
494+
&NaiveDateTime::parse_from_str("2023-04-22 17:01", format)?.and_utc()
495+
)
496+
);
479497

480498
// Date 2400 range
481-
assert!(market_schedule
482-
.can_publish_at(&NaiveDateTime::parse_from_str("2023-12-31 23:59", format)?.and_utc()));
499+
assert!(
500+
market_schedule.can_publish_at(
501+
&NaiveDateTime::parse_from_str("2023-12-31 23:59", format)?.and_utc()
502+
)
503+
);
483504

484505
// Sunday
485-
assert!(market_schedule
486-
.can_publish_at(&NaiveDateTime::parse_from_str("2024-04-14 12:00", format)?.and_utc()));
506+
assert!(
507+
market_schedule.can_publish_at(
508+
&NaiveDateTime::parse_from_str("2024-04-14 12:00", format)?.and_utc()
509+
)
510+
);
487511

488512
// Monday
489-
assert!(market_schedule
490-
.can_publish_at(&NaiveDateTime::parse_from_str("2024-04-15 12:00", format)?.and_utc()));
513+
assert!(
514+
market_schedule.can_publish_at(
515+
&NaiveDateTime::parse_from_str("2024-04-15 12:00", format)?.and_utc()
516+
)
517+
);
491518

492519
Ok(())
493520
}

src/agent/metrics.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ use {
44
lazy_static::lazy_static,
55
prometheus_client::{
66
encoding::{
7-
text::encode,
87
EncodeLabelSet,
8+
text::encode,
99
},
1010
metrics::{
1111
counter::Counter,
@@ -20,17 +20,17 @@ use {
2020
std::{
2121
net::SocketAddr,
2222
sync::{
23-
atomic::AtomicU64,
2423
Arc,
24+
atomic::AtomicU64,
2525
},
2626
},
2727
tokio::sync::Mutex,
2828
warp::{
29-
hyper::StatusCode,
30-
reply,
3129
Filter,
3230
Rejection,
3331
Reply,
32+
hyper::StatusCode,
33+
reply,
3434
},
3535
};
3636

@@ -63,6 +63,7 @@ pub async fn spawn(addr: impl Into<SocketAddr> + 'static) {
6363
.and(warp::path::end())
6464
.and_then(move || async move {
6565
let mut buf = String::new();
66+
#[allow(clippy::needless_borrow)]
6667
let response = encode(&mut buf, &&PROMETHEUS_REGISTRY.lock().await)
6768
.map_err(|e| -> Box<dyn std::error::Error> { e.into() })
6869
.map(|_| Box::new(reply::with_status(buf, StatusCode::OK)))

src/agent/pyth/rpc.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,31 +15,31 @@ use {
1515
},
1616
crate::agent::state,
1717
anyhow::{
18-
anyhow,
1918
Result,
19+
anyhow,
2020
},
2121
futures::future::OptionFuture,
2222
futures_util::{
23+
SinkExt,
2324
stream::{
2425
SplitSink,
2526
SplitStream,
2627
StreamExt,
2728
},
28-
SinkExt,
2929
},
3030
jrpc::{
31-
parse_request,
3231
ErrorCode,
3332
Id,
3433
IdReq,
3534
Request,
3635
Response,
3736
Value,
37+
parse_request,
3838
},
3939
serde::{
40-
de::DeserializeOwned,
4140
Deserialize,
4241
Serialize,
42+
de::DeserializeOwned,
4343
},
4444
serde_this_or_that::{
4545
as_i64,
@@ -57,12 +57,12 @@ use {
5757
},
5858
tracing::instrument,
5959
warp::{
60+
Filter,
6061
ws::{
6162
Message,
6263
WebSocket,
6364
Ws,
6465
},
65-
Filter,
6666
},
6767
};
6868

src/agent/pyth/rpc/get_product.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ use {
55
},
66
crate::agent::state,
77
anyhow::{
8-
anyhow,
98
Result,
9+
anyhow,
1010
},
1111
jrpc::{
1212
Request,

src/agent/pyth/rpc/subscribe_price.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ use {
77
},
88
crate::agent::state,
99
anyhow::{
10-
anyhow,
1110
Result,
11+
anyhow,
1212
},
1313
jrpc::{
1414
Request,

src/agent/pyth/rpc/subscribe_price_sched.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ use {
77
},
88
crate::agent::state,
99
anyhow::{
10-
anyhow,
1110
Result,
11+
anyhow,
1212
},
1313
jrpc::{
1414
Request,

src/agent/pyth/rpc/update_price.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ use {
55
},
66
crate::agent::state,
77
anyhow::{
8-
anyhow,
98
Result,
9+
anyhow,
1010
},
1111
jrpc::{
1212
Request,

0 commit comments

Comments
 (0)