Skip to content

Commit a538fc1

Browse files
authored
chore: rename pyth programs (#143)
1 parent bcd190e commit a538fc1

File tree

5 files changed

+48
-49
lines changed

5 files changed

+48
-49
lines changed

src/agent/services/exporter.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,8 +270,8 @@ mod exporter {
270270
&network_state_rx,
271271
key_store.accumulator_key,
272272
&publish_keypair,
273-
key_store.oracle_program_key,
274-
key_store.publish_program_key,
273+
key_store.pyth_oracle_program_key,
274+
key_store.pyth_price_store_program_key,
275275
publisher_buffer_key,
276276
config.exporter.max_batch_size,
277277
config.exporter.staleness_threshold,

src/agent/services/oracle.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ where
6262
state.clone(),
6363
key_store.mapping_key,
6464
key_store.publish_keypair,
65-
key_store.publish_program_key,
65+
key_store.pyth_price_store_program_key,
6666
config.oracle.max_lookup_batch_size,
6767
)));
6868

@@ -74,7 +74,7 @@ where
7474
config.clone(),
7575
network,
7676
state.clone(),
77-
key_store.oracle_program_key,
77+
key_store.pyth_oracle_program_key,
7878
)
7979
.await
8080
{
@@ -160,7 +160,7 @@ async fn poller<S>(
160160
state: Arc<S>,
161161
mapping_key: Pubkey,
162162
publish_keypair: Option<Keypair>,
163-
publish_program_key: Option<Pubkey>,
163+
pyth_price_store_program_key: Option<Pubkey>,
164164
max_lookup_batch_size: usize,
165165
) where
166166
S: Oracle,
@@ -185,7 +185,7 @@ async fn poller<S>(
185185
network,
186186
mapping_key,
187187
publish_keypair.as_ref(),
188-
publish_program_key,
188+
pyth_price_store_program_key,
189189
&client,
190190
max_lookup_batch_size,
191191
)

src/agent/solana.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -88,49 +88,49 @@ pub mod key_store {
8888
/// to a non-existent file path, the system expects a keypair
8989
/// to be loaded via the remote keypair loader. If the path is
9090
/// valid, the remote keypair loading is disabled.
91-
pub publish_keypair_path: PathBuf,
91+
pub publish_keypair_path: PathBuf,
9292
/// The public key of the Oracle program
9393
#[serde(
9494
serialize_with = "pubkey_string_ser",
9595
deserialize_with = "pubkey_string_de",
9696
alias = "program_key" // for compatibility
9797
)]
98-
pub oracle_program_key: Pubkey,
99-
/// The public key of the Publish program
98+
pub pyth_oracle_program_key: Pubkey,
99+
/// The public key of the pyth-price-store program
100100
#[serde(
101101
serialize_with = "opt_pubkey_string_ser",
102102
deserialize_with = "opt_pubkey_string_de",
103103
default
104104
)]
105-
pub publish_program_key: Option<Pubkey>,
105+
pub pyth_price_store_program_key: Option<Pubkey>,
106106
/// The public key of the root mapping account
107107
#[serde(
108108
serialize_with = "pubkey_string_ser",
109109
deserialize_with = "pubkey_string_de"
110110
)]
111-
pub mapping_key: Pubkey,
111+
pub mapping_key: Pubkey,
112112
/// The public key of the accumulator program.
113113
#[serde(
114114
serialize_with = "opt_pubkey_string_ser",
115115
deserialize_with = "opt_pubkey_string_de",
116116
default
117117
)]
118-
pub accumulator_key: Option<Pubkey>,
118+
pub accumulator_key: Option<Pubkey>,
119119
}
120120

121121
pub struct KeyStore {
122122
/// The keypair used to publish price updates. When None,
123123
/// publishing will not start until a new keypair is supplied
124124
/// via the remote loading endpoint
125-
pub publish_keypair: Option<Keypair>,
125+
pub publish_keypair: Option<Keypair>,
126126
/// Public key of the Oracle program
127-
pub oracle_program_key: Pubkey,
128-
/// Public key of the Publish program
129-
pub publish_program_key: Option<Pubkey>,
127+
pub pyth_oracle_program_key: Pubkey,
128+
/// Public key of the pyth-price-store program
129+
pub pyth_price_store_program_key: Option<Pubkey>,
130130
/// Public key of the root mapping account
131-
pub mapping_key: Pubkey,
131+
pub mapping_key: Pubkey,
132132
/// Public key of the accumulator program (if provided)
133-
pub accumulator_key: Option<Pubkey>,
133+
pub accumulator_key: Option<Pubkey>,
134134
}
135135

136136
impl KeyStore {
@@ -149,8 +149,8 @@ pub mod key_store {
149149

150150
Ok(KeyStore {
151151
publish_keypair,
152-
oracle_program_key: config.oracle_program_key,
153-
publish_program_key: config.publish_program_key,
152+
pyth_oracle_program_key: config.pyth_oracle_program_key,
153+
pyth_price_store_program_key: config.pyth_price_store_program_key,
154154
mapping_key: config.mapping_key,
155155
accumulator_key: config.accumulator_key,
156156
})

src/agent/state/exporter.rs

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -463,8 +463,8 @@ pub async fn publish_batches<S>(
463463
network_state_rx: &watch::Receiver<NetworkState>,
464464
accumulator_key: Option<Pubkey>,
465465
publish_keypair: &Keypair,
466-
oracle_program_key: Pubkey,
467-
publish_program_key: Option<Pubkey>,
466+
pyth_oracle_program_key: Pubkey,
467+
pyth_price_store_program_key: Option<Pubkey>,
468468
publisher_buffer_key: Option<Pubkey>,
469469
max_batch_size: usize,
470470
staleness_threshold: Duration,
@@ -502,8 +502,8 @@ where
502502
network_state,
503503
accumulator_key,
504504
publish_keypair,
505-
oracle_program_key,
506-
publish_program_key,
505+
pyth_oracle_program_key,
506+
pyth_price_store_program_key,
507507
publisher_buffer_key,
508508
batch,
509509
staleness_threshold,
@@ -547,8 +547,8 @@ async fn publish_batch<S>(
547547
network_state: NetworkState,
548548
accumulator_key: Option<Pubkey>,
549549
publish_keypair: &Keypair,
550-
oracle_program_key: Pubkey,
551-
publish_program_key: Option<Pubkey>,
550+
pyth_oracle_program_key: Pubkey,
551+
pyth_price_store_program_key: Option<Pubkey>,
552552
publisher_buffer_key: Option<Pubkey>,
553553
batch: &[PermissionedUpdate],
554554
staleness_threshold: Duration,
@@ -592,12 +592,11 @@ where
592592
updates.push(update);
593593
}
594594

595-
if let Some(publish_program_key) = publish_program_key {
596-
let instruction = create_instruction_with_publish_program(
595+
if let Some(pyth_price_store_program_key) = pyth_price_store_program_key {
596+
let instruction = create_instruction_with_price_store_program(
597597
publish_keypair.pubkey(),
598-
publish_program_key,
599-
publisher_buffer_key
600-
.context("must specify publisher_buffer_key if publish_program_key is specified")?,
598+
pyth_price_store_program_key,
599+
publisher_buffer_key.context("failed to fetch publisher buffer key")?,
601600
updates,
602601
)?;
603602
instructions.push(instruction);
@@ -606,7 +605,7 @@ where
606605
let instruction = if let Some(accumulator_program_key) = accumulator_key {
607606
create_instruction_with_accumulator(
608607
publish_keypair.pubkey(),
609-
oracle_program_key,
608+
pyth_oracle_program_key,
610609
Pubkey::from(update.feed_id.to_bytes()),
611610
&update.info,
612611
network_state.current_slot,
@@ -615,7 +614,7 @@ where
615614
} else {
616615
create_instruction_without_accumulator(
617616
publish_keypair.pubkey(),
618-
oracle_program_key,
617+
pyth_oracle_program_key,
619618
Pubkey::from(update.feed_id.to_bytes()),
620619
&update.info,
621620
network_state.current_slot,
@@ -775,13 +774,13 @@ where
775774

776775
fn create_instruction_without_accumulator(
777776
publish_pubkey: Pubkey,
778-
oracle_program_key: Pubkey,
777+
pyth_oracle_program_key: Pubkey,
779778
price_id: Pubkey,
780779
price_info: &PriceInfo,
781780
current_slot: u64,
782781
) -> Result<Instruction> {
783782
Ok(Instruction {
784-
program_id: oracle_program_key,
783+
program_id: pyth_oracle_program_key,
785784
accounts: vec![
786785
AccountMeta {
787786
pubkey: publish_pubkey,
@@ -816,9 +815,9 @@ fn create_instruction_without_accumulator(
816815
})
817816
}
818817

819-
fn create_instruction_with_publish_program(
818+
fn create_instruction_with_price_store_program(
820819
publish_pubkey: Pubkey,
821-
publish_program_key: Pubkey,
820+
pyth_price_store_program_key: Pubkey,
822821
publisher_buffer_key: Pubkey,
823822
prices: Vec<PermissionedUpdate>,
824823
) -> Result<Instruction> {
@@ -829,7 +828,7 @@ fn create_instruction_with_publish_program(
829828
};
830829
let (publisher_config_key, publisher_config_bump) = Pubkey::find_program_address(
831830
&[PUBLISHER_CONFIG_SEED.as_bytes(), &publish_pubkey.to_bytes()],
832-
&publish_program_key,
831+
&pyth_price_store_program_key,
833832
);
834833

835834
let mut values = Vec::new();
@@ -851,7 +850,7 @@ fn create_instruction_with_publish_program(
851850
data.extend(cast_slice(&values));
852851

853852
let instruction = Instruction {
854-
program_id: publish_program_key,
853+
program_id: pyth_price_store_program_key,
855854
accounts: vec![
856855
AccountMeta {
857856
pubkey: publish_pubkey,
@@ -876,7 +875,7 @@ fn create_instruction_with_publish_program(
876875

877876
fn create_instruction_with_accumulator(
878877
publish_pubkey: Pubkey,
879-
oracle_program_key: Pubkey,
878+
pyth_oracle_program_key: Pubkey,
880879
price_id: Pubkey,
881880
price_info: &PriceInfo,
882881
current_slot: u64,
@@ -889,7 +888,7 @@ fn create_instruction_with_accumulator(
889888

890889
let (oracle_auth_pda, _) = Pubkey::find_program_address(
891890
&[b"upd_price_write", &accumulator_program_key.to_bytes()],
892-
&oracle_program_key,
891+
&pyth_oracle_program_key,
893892
);
894893

895894
let (accumulator_data_pubkey, _accumulator_data_pubkey) = Pubkey::find_program_address(
@@ -902,7 +901,7 @@ fn create_instruction_with_accumulator(
902901
);
903902

904903
Ok(Instruction {
905-
program_id: oracle_program_key,
904+
program_id: pyth_oracle_program_key,
906905
accounts: vec![
907906
AccountMeta {
908907
pubkey: publish_pubkey,

src/agent/state/oracle.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ pub trait Oracle {
196196
network: Network,
197197
mapping_key: Pubkey,
198198
publish_keypair: Option<&Keypair>,
199-
publish_program_key: Option<Pubkey>,
199+
pyth_price_store_program_key: Option<Pubkey>,
200200
rpc_client: &RpcClient,
201201
max_lookup_batch_size: usize,
202202
) -> Result<()>;
@@ -271,7 +271,7 @@ where
271271
network: Network,
272272
mapping_key: Pubkey,
273273
publish_keypair: Option<&Keypair>,
274-
publish_program_key: Option<Pubkey>,
274+
pyth_price_store_program_key: Option<Pubkey>,
275275
rpc_client: &RpcClient,
276276
max_lookup_batch_size: usize,
277277
) -> Result<()> {
@@ -317,12 +317,12 @@ where
317317
}
318318

319319
let mut publisher_buffer_key = None;
320-
if let (Some(publish_program_key), Some(publish_keypair)) =
321-
(publish_program_key, publish_keypair)
320+
if let (Some(pyth_price_store_program_key), Some(publish_keypair)) =
321+
(pyth_price_store_program_key, publish_keypair)
322322
{
323323
match fetch_publisher_buffer_key(
324324
rpc_client,
325-
publish_program_key,
325+
pyth_price_store_program_key,
326326
publish_keypair.pubkey(),
327327
)
328328
.await
@@ -396,15 +396,15 @@ where
396396

397397
async fn fetch_publisher_buffer_key(
398398
rpc_client: &RpcClient,
399-
publish_program_key: Pubkey,
399+
pyth_price_store_program_key: Pubkey,
400400
publisher_pubkey: Pubkey,
401401
) -> Result<Pubkey> {
402402
let (publisher_config_key, _bump) = Pubkey::find_program_address(
403403
&[
404404
PUBLISHER_CONFIG_SEED.as_bytes(),
405405
&publisher_pubkey.to_bytes(),
406406
],
407-
&publish_program_key,
407+
&pyth_price_store_program_key,
408408
);
409409
let data = rpc_client.get_account_data(&publisher_config_key).await?;
410410
let config = pyth_price_store::accounts::publisher_config::read(&data)?;

0 commit comments

Comments
 (0)