Skip to content
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

feat: support batch publish #140

Merged
merged 5 commits into from
Sep 10, 2024
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
14 changes: 13 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "pyth-agent"
version = "2.10.4"
version = "2.11.0"
edition = "2021"

[[bin]]
Expand Down Expand Up @@ -56,6 +56,8 @@ tracing-opentelemetry = "0.24.0"
opentelemetry = "0.23.0"
opentelemetry_sdk = { version = "0.23.0", features = ["rt-tokio"]}
opentelemetry-otlp = { version = "0.16.0" }
pyth-price-store = "0.1.0"
bytemuck = "1.13.0"

[dev-dependencies]
tokio-util = { version = "0.7.10", features = ["full"] }
Expand Down
5 changes: 4 additions & 1 deletion src/agent/services/exporter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,14 +261,17 @@ mod exporter {
config.exporter.staleness_threshold,
config.exporter.unchanged_publish_threshold,
).await {
let publisher_buffer_key = Exporter::get_publisher_buffer_key(&*state).await;
if let Err(err) = publish_batches(
state.clone(),
client.clone(),
network,
&network_state_rx,
key_store.accumulator_key,
&publish_keypair,
key_store.program_key,
key_store.oracle_program_key,
key_store.publish_program_key,
publisher_buffer_key,
config.exporter.max_batch_size,
config.exporter.staleness_threshold,
config.exporter.compute_unit_limit,
Expand Down
5 changes: 4 additions & 1 deletion src/agent/services/oracle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ where
state.clone(),
key_store.mapping_key,
key_store.publish_keypair,
key_store.publish_program_key,
config.oracle.max_lookup_batch_size,
)));

Expand All @@ -73,7 +74,7 @@ where
config.clone(),
network,
state.clone(),
key_store.program_key,
key_store.oracle_program_key,
)
.await
{
Expand Down Expand Up @@ -159,6 +160,7 @@ async fn poller<S>(
state: Arc<S>,
mapping_key: Pubkey,
publish_keypair: Option<Keypair>,
publish_program_key: Option<Pubkey>,
max_lookup_batch_size: usize,
) where
S: Oracle,
Expand All @@ -183,6 +185,7 @@ async fn poller<S>(
network,
mapping_key,
publish_keypair.as_ref(),
publish_program_key,
&client,
max_lookup_batch_size,
)
Expand Down
25 changes: 18 additions & 7 deletions src/agent/solana.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,17 @@ pub mod key_store {
/// The public key of the Oracle program
#[serde(
serialize_with = "pubkey_string_ser",
deserialize_with = "pubkey_string_de"
deserialize_with = "pubkey_string_de",
alias = "program_key" // for compatibility
)]
pub oracle_program_key: Pubkey,
/// The public key of the Publish program
#[serde(
serialize_with = "opt_pubkey_string_ser",
deserialize_with = "opt_pubkey_string_de",
default
)]
pub program_key: Pubkey,
pub publish_program_key: Option<Pubkey>,
/// The public key of the root mapping account
#[serde(
serialize_with = "pubkey_string_ser",
Expand All @@ -114,13 +122,15 @@ pub mod key_store {
/// The keypair used to publish price updates. When None,
/// publishing will not start until a new keypair is supplied
/// via the remote loading endpoint
pub publish_keypair: Option<Keypair>,
pub publish_keypair: Option<Keypair>,
/// Public key of the Oracle program
pub program_key: Pubkey,
pub oracle_program_key: Pubkey,
/// Public key of the Publish program
pub publish_program_key: Option<Pubkey>,
/// Public key of the root mapping account
pub mapping_key: Pubkey,
pub mapping_key: Pubkey,
/// Public key of the accumulator program (if provided)
pub accumulator_key: Option<Pubkey>,
pub accumulator_key: Option<Pubkey>,
}

impl KeyStore {
Expand All @@ -139,7 +149,8 @@ pub mod key_store {

Ok(KeyStore {
publish_keypair,
program_key: config.program_key,
oracle_program_key: config.oracle_program_key,
publish_program_key: config.publish_program_key,
mapping_key: config.mapping_key,
accumulator_key: config.accumulator_key,
})
Expand Down
Loading
Loading