diff --git a/src/agent/services/exporter.rs b/src/agent/services/exporter.rs index 9825bdd..2500b9d 100644 --- a/src/agent/services/exporter.rs +++ b/src/agent/services/exporter.rs @@ -270,8 +270,8 @@ mod exporter { &network_state_rx, key_store.accumulator_key, &publish_keypair, - key_store.oracle_program_key, - key_store.publish_program_key, + key_store.pyth_oracle_program_key, + key_store.pyth_price_store_program_key, publisher_buffer_key, config.exporter.max_batch_size, config.exporter.staleness_threshold, diff --git a/src/agent/services/oracle.rs b/src/agent/services/oracle.rs index 7de2194..c82b98f 100644 --- a/src/agent/services/oracle.rs +++ b/src/agent/services/oracle.rs @@ -62,7 +62,7 @@ where state.clone(), key_store.mapping_key, key_store.publish_keypair, - key_store.publish_program_key, + key_store.pyth_price_store_program_key, config.oracle.max_lookup_batch_size, ))); @@ -74,7 +74,7 @@ where config.clone(), network, state.clone(), - key_store.oracle_program_key, + key_store.pyth_oracle_program_key, ) .await { @@ -160,7 +160,7 @@ async fn poller( state: Arc, mapping_key: Pubkey, publish_keypair: Option, - publish_program_key: Option, + pyth_price_store_program_key: Option, max_lookup_batch_size: usize, ) where S: Oracle, @@ -185,7 +185,7 @@ async fn poller( network, mapping_key, publish_keypair.as_ref(), - publish_program_key, + pyth_price_store_program_key, &client, max_lookup_batch_size, ) diff --git a/src/agent/solana.rs b/src/agent/solana.rs index 3ea5858..5ca207c 100644 --- a/src/agent/solana.rs +++ b/src/agent/solana.rs @@ -88,49 +88,49 @@ pub mod key_store { /// to a non-existent file path, the system expects a keypair /// to be loaded via the remote keypair loader. If the path is /// valid, the remote keypair loading is disabled. - pub publish_keypair_path: PathBuf, + pub publish_keypair_path: PathBuf, /// The public key of the Oracle program #[serde( serialize_with = "pubkey_string_ser", deserialize_with = "pubkey_string_de", alias = "program_key" // for compatibility )] - pub oracle_program_key: Pubkey, - /// The public key of the Publish program + pub pyth_oracle_program_key: Pubkey, + /// The public key of the pyth-price-store program #[serde( serialize_with = "opt_pubkey_string_ser", deserialize_with = "opt_pubkey_string_de", default )] - pub publish_program_key: Option, + pub pyth_price_store_program_key: Option, /// The public key of the root mapping account #[serde( serialize_with = "pubkey_string_ser", deserialize_with = "pubkey_string_de" )] - pub mapping_key: Pubkey, + pub mapping_key: Pubkey, /// The public key of the accumulator program. #[serde( serialize_with = "opt_pubkey_string_ser", deserialize_with = "opt_pubkey_string_de", default )] - pub accumulator_key: Option, + pub accumulator_key: Option, } pub struct KeyStore { /// 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, + pub publish_keypair: Option, /// Public key of the Oracle program - pub oracle_program_key: Pubkey, - /// Public key of the Publish program - pub publish_program_key: Option, + pub pyth_oracle_program_key: Pubkey, + /// Public key of the pyth-price-store program + pub pyth_price_store_program_key: Option, /// 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, + pub accumulator_key: Option, } impl KeyStore { @@ -149,8 +149,8 @@ pub mod key_store { Ok(KeyStore { publish_keypair, - oracle_program_key: config.oracle_program_key, - publish_program_key: config.publish_program_key, + pyth_oracle_program_key: config.pyth_oracle_program_key, + pyth_price_store_program_key: config.pyth_price_store_program_key, mapping_key: config.mapping_key, accumulator_key: config.accumulator_key, }) diff --git a/src/agent/state/exporter.rs b/src/agent/state/exporter.rs index 199b814..151a6f2 100644 --- a/src/agent/state/exporter.rs +++ b/src/agent/state/exporter.rs @@ -463,8 +463,8 @@ pub async fn publish_batches( network_state_rx: &watch::Receiver, accumulator_key: Option, publish_keypair: &Keypair, - oracle_program_key: Pubkey, - publish_program_key: Option, + pyth_oracle_program_key: Pubkey, + pyth_price_store_program_key: Option, publisher_buffer_key: Option, max_batch_size: usize, staleness_threshold: Duration, @@ -502,8 +502,8 @@ where network_state, accumulator_key, publish_keypair, - oracle_program_key, - publish_program_key, + pyth_oracle_program_key, + pyth_price_store_program_key, publisher_buffer_key, batch, staleness_threshold, @@ -547,8 +547,8 @@ async fn publish_batch( network_state: NetworkState, accumulator_key: Option, publish_keypair: &Keypair, - oracle_program_key: Pubkey, - publish_program_key: Option, + pyth_oracle_program_key: Pubkey, + pyth_price_store_program_key: Option, publisher_buffer_key: Option, batch: &[PermissionedUpdate], staleness_threshold: Duration, @@ -592,12 +592,11 @@ where updates.push(update); } - if let Some(publish_program_key) = publish_program_key { - let instruction = create_instruction_with_publish_program( + if let Some(pyth_price_store_program_key) = pyth_price_store_program_key { + let instruction = create_instruction_with_price_store_program( publish_keypair.pubkey(), - publish_program_key, - publisher_buffer_key - .context("must specify publisher_buffer_key if publish_program_key is specified")?, + pyth_price_store_program_key, + publisher_buffer_key.context("failed to fetch publisher buffer key")?, updates, )?; instructions.push(instruction); @@ -606,7 +605,7 @@ where let instruction = if let Some(accumulator_program_key) = accumulator_key { create_instruction_with_accumulator( publish_keypair.pubkey(), - oracle_program_key, + pyth_oracle_program_key, Pubkey::from(update.feed_id.to_bytes()), &update.info, network_state.current_slot, @@ -615,7 +614,7 @@ where } else { create_instruction_without_accumulator( publish_keypair.pubkey(), - oracle_program_key, + pyth_oracle_program_key, Pubkey::from(update.feed_id.to_bytes()), &update.info, network_state.current_slot, @@ -775,13 +774,13 @@ where fn create_instruction_without_accumulator( publish_pubkey: Pubkey, - oracle_program_key: Pubkey, + pyth_oracle_program_key: Pubkey, price_id: Pubkey, price_info: &PriceInfo, current_slot: u64, ) -> Result { Ok(Instruction { - program_id: oracle_program_key, + program_id: pyth_oracle_program_key, accounts: vec![ AccountMeta { pubkey: publish_pubkey, @@ -816,9 +815,9 @@ fn create_instruction_without_accumulator( }) } -fn create_instruction_with_publish_program( +fn create_instruction_with_price_store_program( publish_pubkey: Pubkey, - publish_program_key: Pubkey, + pyth_price_store_program_key: Pubkey, publisher_buffer_key: Pubkey, prices: Vec, ) -> Result { @@ -829,7 +828,7 @@ fn create_instruction_with_publish_program( }; let (publisher_config_key, publisher_config_bump) = Pubkey::find_program_address( &[PUBLISHER_CONFIG_SEED.as_bytes(), &publish_pubkey.to_bytes()], - &publish_program_key, + &pyth_price_store_program_key, ); let mut values = Vec::new(); @@ -851,7 +850,7 @@ fn create_instruction_with_publish_program( data.extend(cast_slice(&values)); let instruction = Instruction { - program_id: publish_program_key, + program_id: pyth_price_store_program_key, accounts: vec![ AccountMeta { pubkey: publish_pubkey, @@ -876,7 +875,7 @@ fn create_instruction_with_publish_program( fn create_instruction_with_accumulator( publish_pubkey: Pubkey, - oracle_program_key: Pubkey, + pyth_oracle_program_key: Pubkey, price_id: Pubkey, price_info: &PriceInfo, current_slot: u64, @@ -889,7 +888,7 @@ fn create_instruction_with_accumulator( let (oracle_auth_pda, _) = Pubkey::find_program_address( &[b"upd_price_write", &accumulator_program_key.to_bytes()], - &oracle_program_key, + &pyth_oracle_program_key, ); let (accumulator_data_pubkey, _accumulator_data_pubkey) = Pubkey::find_program_address( @@ -902,7 +901,7 @@ fn create_instruction_with_accumulator( ); Ok(Instruction { - program_id: oracle_program_key, + program_id: pyth_oracle_program_key, accounts: vec![ AccountMeta { pubkey: publish_pubkey, diff --git a/src/agent/state/oracle.rs b/src/agent/state/oracle.rs index c09a2ee..526545f 100644 --- a/src/agent/state/oracle.rs +++ b/src/agent/state/oracle.rs @@ -196,7 +196,7 @@ pub trait Oracle { network: Network, mapping_key: Pubkey, publish_keypair: Option<&Keypair>, - publish_program_key: Option, + pyth_price_store_program_key: Option, rpc_client: &RpcClient, max_lookup_batch_size: usize, ) -> Result<()>; @@ -271,7 +271,7 @@ where network: Network, mapping_key: Pubkey, publish_keypair: Option<&Keypair>, - publish_program_key: Option, + pyth_price_store_program_key: Option, rpc_client: &RpcClient, max_lookup_batch_size: usize, ) -> Result<()> { @@ -317,12 +317,12 @@ where } let mut publisher_buffer_key = None; - if let (Some(publish_program_key), Some(publish_keypair)) = - (publish_program_key, publish_keypair) + if let (Some(pyth_price_store_program_key), Some(publish_keypair)) = + (pyth_price_store_program_key, publish_keypair) { match fetch_publisher_buffer_key( rpc_client, - publish_program_key, + pyth_price_store_program_key, publish_keypair.pubkey(), ) .await @@ -396,7 +396,7 @@ where async fn fetch_publisher_buffer_key( rpc_client: &RpcClient, - publish_program_key: Pubkey, + pyth_price_store_program_key: Pubkey, publisher_pubkey: Pubkey, ) -> Result { let (publisher_config_key, _bump) = Pubkey::find_program_address( @@ -404,7 +404,7 @@ async fn fetch_publisher_buffer_key( PUBLISHER_CONFIG_SEED.as_bytes(), &publisher_pubkey.to_bytes(), ], - &publish_program_key, + &pyth_price_store_program_key, ); let data = rpc_client.get_account_data(&publisher_config_key).await?; let config = pyth_price_store::accounts::publisher_config::read(&data)?;