Skip to content

Commit bcd190e

Browse files
authored
feat: support batch publish (#140)
* feat: support batch publish * feat: update to new batch publish instruction format * feat: fetch publisher buffer key * chore: update publisher program dependency * chore: bump agent version to 2.11.0
1 parent 2872c68 commit bcd190e

File tree

7 files changed

+261
-80
lines changed

7 files changed

+261
-80
lines changed

Cargo.lock

Lines changed: 13 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "pyth-agent"
3-
version = "2.10.4"
3+
version = "2.11.0"
44
edition = "2021"
55

66
[[bin]]
@@ -56,6 +56,8 @@ tracing-opentelemetry = "0.24.0"
5656
opentelemetry = "0.23.0"
5757
opentelemetry_sdk = { version = "0.23.0", features = ["rt-tokio"]}
5858
opentelemetry-otlp = { version = "0.16.0" }
59+
pyth-price-store = "0.1.0"
60+
bytemuck = "1.13.0"
5961

6062
[dev-dependencies]
6163
tokio-util = { version = "0.7.10", features = ["full"] }

src/agent/services/exporter.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,14 +262,17 @@ mod exporter {
262262
config.exporter.staleness_threshold,
263263
config.exporter.unchanged_publish_threshold,
264264
).await {
265+
let publisher_buffer_key = Exporter::get_publisher_buffer_key(&*state).await;
265266
if let Err(err) = publish_batches(
266267
state.clone(),
267268
client.clone(),
268269
network,
269270
&network_state_rx,
270271
key_store.accumulator_key,
271272
&publish_keypair,
272-
key_store.program_key,
273+
key_store.oracle_program_key,
274+
key_store.publish_program_key,
275+
publisher_buffer_key,
273276
config.exporter.max_batch_size,
274277
config.exporter.staleness_threshold,
275278
config.exporter.compute_unit_limit,

src/agent/services/oracle.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ where
6262
state.clone(),
6363
key_store.mapping_key,
6464
key_store.publish_keypair,
65+
key_store.publish_program_key,
6566
config.oracle.max_lookup_batch_size,
6667
)));
6768

@@ -73,7 +74,7 @@ where
7374
config.clone(),
7475
network,
7576
state.clone(),
76-
key_store.program_key,
77+
key_store.oracle_program_key,
7778
)
7879
.await
7980
{
@@ -159,6 +160,7 @@ async fn poller<S>(
159160
state: Arc<S>,
160161
mapping_key: Pubkey,
161162
publish_keypair: Option<Keypair>,
163+
publish_program_key: Option<Pubkey>,
162164
max_lookup_batch_size: usize,
163165
) where
164166
S: Oracle,
@@ -183,6 +185,7 @@ async fn poller<S>(
183185
network,
184186
mapping_key,
185187
publish_keypair.as_ref(),
188+
publish_program_key,
186189
&client,
187190
max_lookup_batch_size,
188191
)

src/agent/solana.rs

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,17 @@ pub mod key_store {
9292
/// The public key of the Oracle program
9393
#[serde(
9494
serialize_with = "pubkey_string_ser",
95-
deserialize_with = "pubkey_string_de"
95+
deserialize_with = "pubkey_string_de",
96+
alias = "program_key" // for compatibility
97+
)]
98+
pub oracle_program_key: Pubkey,
99+
/// The public key of the Publish program
100+
#[serde(
101+
serialize_with = "opt_pubkey_string_ser",
102+
deserialize_with = "opt_pubkey_string_de",
103+
default
96104
)]
97-
pub program_key: Pubkey,
105+
pub publish_program_key: Option<Pubkey>,
98106
/// The public key of the root mapping account
99107
#[serde(
100108
serialize_with = "pubkey_string_ser",
@@ -114,13 +122,15 @@ pub mod key_store {
114122
/// The keypair used to publish price updates. When None,
115123
/// publishing will not start until a new keypair is supplied
116124
/// via the remote loading endpoint
117-
pub publish_keypair: Option<Keypair>,
125+
pub publish_keypair: Option<Keypair>,
118126
/// Public key of the Oracle program
119-
pub program_key: Pubkey,
127+
pub oracle_program_key: Pubkey,
128+
/// Public key of the Publish program
129+
pub publish_program_key: Option<Pubkey>,
120130
/// Public key of the root mapping account
121-
pub mapping_key: Pubkey,
131+
pub mapping_key: Pubkey,
122132
/// Public key of the accumulator program (if provided)
123-
pub accumulator_key: Option<Pubkey>,
133+
pub accumulator_key: Option<Pubkey>,
124134
}
125135

126136
impl KeyStore {
@@ -139,7 +149,8 @@ pub mod key_store {
139149

140150
Ok(KeyStore {
141151
publish_keypair,
142-
program_key: config.program_key,
152+
oracle_program_key: config.oracle_program_key,
153+
publish_program_key: config.publish_program_key,
143154
mapping_key: config.mapping_key,
144155
accumulator_key: config.accumulator_key,
145156
})

0 commit comments

Comments
 (0)