Quellcode durchsuchen

use types from abigen

Tejas Badadare vor 6 Monaten
Ursprung
Commit
11a0dc68db

+ 1 - 1
apps/argus/src/actors/chain_price_listener.rs

@@ -62,7 +62,7 @@ impl Actor for ChainPriceListener {
                     chain_id = chain_id.clone(),
                     "Polling for on-chain price updates"
                 );
-                todo!()
+                // todo!()
             }
         });
 

+ 5 - 3
apps/argus/src/actors/controller.rs

@@ -1,7 +1,8 @@
 use {
     crate::{
         actors::types::*,
-        adapters::types::{PriceId, Subscription, SubscriptionId},
+        adapters::ethereum::pyth_pulse::SubscriptionParams,
+        adapters::types::{PriceId, SubscriptionId},
     },
     anyhow::Result,
     ractor::{Actor, ActorProcessingErr, ActorRef},
@@ -22,7 +23,7 @@ pub struct ControllerState {
     update_interval: Duration,
     update_loop_running: bool,
     stop_sender: Option<watch::Sender<bool>>,
-    active_subscriptions: HashMap<SubscriptionId, Subscription>,
+    active_subscriptions: HashMap<SubscriptionId, SubscriptionParams>,
     feed_ids: HashSet<PriceId>,
 }
 
@@ -85,8 +86,9 @@ impl Actor for Controller {
         match message {
             ControllerMessage::PerformUpdate => {
                 // Main processing logic. Keep active subscriptions up-to-date, check for price updates, and push them to the chain.
-                todo!()
+                tracing::info!("Performing update (todo)");
             }
         }
+        Ok(())
     }
 }

+ 11 - 11
apps/argus/src/actors/price_pusher.rs

@@ -10,7 +10,7 @@ use {
 };
 
 pub struct PricePusherState {
-    chain_id: String,
+    chain_name: String,
     contract: Arc<dyn UpdateChainPrices + Send + Sync>,
     pyth_price_client: Arc<dyn ReadPythPrices + Send + Sync>,
     backoff_policy: ExponentialBackoff,
@@ -30,10 +30,10 @@ impl Actor for PricePusher {
     async fn pre_start(
         &self,
         _myself: ActorRef<Self::Msg>,
-        (chain_id, contract, hermes_client, backoff_policy): Self::Arguments,
+        (chain_name, contract, hermes_client, backoff_policy): Self::Arguments,
     ) -> Result<Self::State, ActorProcessingErr> {
         let state = PricePusherState {
-            chain_id,
+            chain_name,
             contract,
             pyth_price_client: hermes_client,
             backoff_policy,
@@ -71,8 +71,8 @@ impl Actor for PricePusher {
                             {
                                 Ok(tx_hash) => {
                                     tracing::info!(
-                                        chain_id = state.chain_id,
-                                        subscription_id = push_request.subscription_id,
+                                        chain_id = state.chain_name,
+                                        subscription_id = push_request.subscription_id.to_string(),
                                         tx_hash = tx_hash.to_string(),
                                         attempt = attempt,
                                         "Successfully pushed price updates"
@@ -82,8 +82,8 @@ impl Actor for PricePusher {
                                 Err(e) => {
                                     if let Some(duration) = backoff.next_backoff() {
                                         tracing::warn!(
-                                            chain_id = state.chain_id,
-                                            subscription_id = push_request.subscription_id,
+                                            chain_id = state.chain_name,
+                                            subscription_id = push_request.subscription_id.to_string(),
                                             error = %e,
                                             attempt = attempt,
                                             retry_after_ms = duration.as_millis(),
@@ -92,8 +92,8 @@ impl Actor for PricePusher {
                                         time::sleep(duration).await;
                                     } else {
                                         tracing::error!(
-                                            chain_id = state.chain_id,
-                                            subscription_id = push_request.subscription_id,
+                                            chain_id = state.chain_name,
+                                            subscription_id = push_request.subscription_id.to_string(),
                                             error = %e,
                                             attempt = attempt,
                                             "Failed to push price updates, giving up"
@@ -106,8 +106,8 @@ impl Actor for PricePusher {
                     }
                     Err(e) => {
                         tracing::error!(
-                            chain_id = state.chain_id,
-                            subscription_id = push_request.subscription_id,
+                            chain_id = state.chain_name,
+                            subscription_id = push_request.subscription_id.to_string(),
                             error = %e,
                             "Failed to get Pyth price update data"
                         );

+ 24 - 11
apps/argus/src/actors/subscription_listener.rs

@@ -1,6 +1,7 @@
+use crate::adapters::ethereum::pyth_pulse::SubscriptionParams;
 use {
     super::SubscriptionListenerMessage,
-    crate::adapters::types::{ReadChainSubscriptions, Subscription, SubscriptionId},
+    crate::adapters::types::{ReadChainSubscriptions, SubscriptionId},
     anyhow::Result,
     ractor::{Actor, ActorProcessingErr, ActorRef},
     std::{
@@ -15,7 +16,7 @@ use {
 pub struct SubscriptionListenerState {
     pub chain_name: String,
     pub contract: Arc<dyn ReadChainSubscriptions + Send + Sync>,
-    pub active_subscriptions: HashMap<SubscriptionId, Subscription>,
+    pub active_subscriptions: HashMap<SubscriptionId, SubscriptionParams>,
     pub poll_interval: Duration,
 }
 
@@ -23,6 +24,13 @@ impl SubscriptionListenerState {
     async fn refresh_subscriptions(&mut self) -> Result<()> {
         let subscriptions = self.contract.get_active_subscriptions().await?;
 
+        tracing::info!(
+            chain_name = self.chain_name,
+            subscription_count = subscriptions.len(),
+            subscription_ids = ?subscriptions.keys().collect::<Vec<_>>(),
+            "Retrieved active subscriptions"
+        );
+
         let old_ids: HashSet<_> = self.active_subscriptions.keys().cloned().collect();
         let new_ids: HashSet<_> = subscriptions.keys().cloned().collect();
 
@@ -36,6 +44,11 @@ impl SubscriptionListenerState {
                 removed = removed,
                 "Subscription changes detected"
             );
+        } else {
+            tracing::debug!(
+                chain_name = self.chain_name,
+                "No subscription changes detected"
+            );
         }
 
         self.active_subscriptions = subscriptions;
@@ -59,39 +72,39 @@ impl Actor for SubscriptionListener {
         myself: ActorRef<Self::Msg>,
         (chain_name, contract, poll_interval): Self::Arguments,
     ) -> Result<Self::State, ActorProcessingErr> {
-        let mut listener = SubscriptionListenerState {
+        let mut state = SubscriptionListenerState {
             chain_name,
             contract,
             active_subscriptions: HashMap::new(),
             poll_interval,
         };
 
-        match listener.refresh_subscriptions().await {
+        match state.refresh_subscriptions().await {
             Ok(_) => {
                 tracing::info!(
-                    chain_name = listener.chain_name,
+                    chain_name = state.chain_name,
                     "Loaded {} active subscriptions",
-                    listener.active_subscriptions.len()
+                    state.active_subscriptions.len()
                 );
             }
             Err(e) => {
                 tracing::error!(
-                    chain_name = listener.chain_name,
+                    chain_name = state.chain_name,
                     error = %e,
                     "Failed to load active subscriptions"
                 );
             }
         }
 
-        if let Err(e) = listener.contract.subscribe_to_subscription_events().await {
+        if let Err(e) = state.contract.subscribe_to_subscription_events().await {
             tracing::error!(
-                chain_name = listener.chain_name,
+                chain_name = state.chain_name,
                 error = %e,
                 "Failed to subscribe to contract events"
             );
         }
 
-        let poll_interval = listener.poll_interval;
+        let poll_interval = state.poll_interval;
         tokio::spawn(async move {
             let mut interval = time::interval(poll_interval);
             loop {
@@ -100,7 +113,7 @@ impl Actor for SubscriptionListener {
             }
         });
 
-        Ok(listener)
+        Ok(state)
     }
 
     async fn handle(

+ 9 - 4
apps/argus/src/adapters/contract.rs

@@ -1,3 +1,4 @@
+use super::ethereum::pyth_pulse;
 use super::{ethereum::PythPulse, types::*};
 use anyhow::Result;
 use async_trait::async_trait;
@@ -5,7 +6,6 @@ use ethers::providers::Middleware;
 use ethers::types::H256;
 use std::collections::HashMap;
 
-// TODO: implement retries & backoff policy
 #[async_trait]
 pub trait GetChainPrices {
     async fn get_price_unsafe(
@@ -42,7 +42,7 @@ impl<M: Middleware + 'static> UpdateChainPrices for PythPulse<M> {
         update_data: &[Vec<u8>],
     ) -> Result<H256> {
         tracing::debug!(
-            subscription_id = subscription_id,
+            subscription_id = subscription_id.to_string(),
             price_ids_count = price_ids.len(),
             update_data_count = update_data.len(),
             "Updating price feeds on-chain via PythPulse"
@@ -53,8 +53,13 @@ impl<M: Middleware + 'static> UpdateChainPrices for PythPulse<M> {
 
 #[async_trait]
 impl<M: Middleware + 'static> ReadChainSubscriptions for PythPulse<M> {
-    async fn get_active_subscriptions(&self) -> Result<HashMap<SubscriptionId, Subscription>> {
-        Ok(HashMap::new())
+    async fn get_active_subscriptions(
+        &self,
+    ) -> Result<HashMap<SubscriptionId, pyth_pulse::SubscriptionParams>> {
+        // TODO: handle pagination
+        let (ids, sub_params, _total_count) =
+            self.get_active_subscriptions(0.into(), 1000.into()).await?;
+        Ok(ids.into_iter().zip(sub_params).collect())
     }
 
     async fn subscribe_to_subscription_events(&self) -> Result<()> {

+ 3 - 3
apps/argus/src/adapters/ethereum.rs

@@ -1,5 +1,5 @@
 use {
-    crate::{api::ChainId, config::EthereumConfig},
+    crate::{api::ChainName, config::EthereumConfig},
     anyhow::{Error, Result},
     ethers::{
         contract::abigen,
@@ -88,7 +88,7 @@ impl InstrumentedSignablePythContract {
     pub async fn from_config(
         chain_config: &EthereumConfig,
         private_key: &str,
-        chain_id: ChainId,
+        chain_id: ChainName,
         metrics: Arc<RpcMetrics>,
     ) -> Result<Self> {
         let provider = TracedClient::new(chain_id, &chain_config.geth_rpc_addr, metrics)?;
@@ -110,7 +110,7 @@ impl PythContract {
 impl InstrumentedPythContract {
     pub fn from_config(
         chain_config: &EthereumConfig,
-        chain_id: ChainId,
+        chain_id: ChainName,
         metrics: Arc<RpcMetrics>,
     ) -> Result<Self> {
         let provider = TracedClient::new(chain_id, &chain_config.geth_rpc_addr, metrics)?;

+ 4 - 3
apps/argus/src/adapters/hermes.rs

@@ -1,14 +1,15 @@
 use super::types::*;
 use anyhow::Result;
-
+use async_trait::async_trait;
 pub struct HermesClient;
 
+#[async_trait]
 impl ReadPythPrices for HermesClient {
-    async fn get_latest_prices(&self, feed_ids: &[PriceId]) -> Result<Vec<Vec<u8>>> {
+    async fn get_latest_prices(&self, _feed_ids: &[PriceId]) -> Result<Vec<Vec<u8>>> {
         todo!()
     }
 
-    async fn subscribe_to_price_updates(&self, feed_ids: &[PriceId]) -> Result<()> {
+    async fn subscribe_to_price_updates(&self, _feed_ids: &[PriceId]) -> Result<()> {
         todo!()
     }
 }

+ 7 - 25
apps/argus/src/adapters/types.rs

@@ -1,9 +1,11 @@
 use anyhow::Result;
 use async_trait::async_trait;
-use ethers::types::{Address, H256, U256};
+use ethers::types::{H256, U256};
 use serde::{Deserialize, Serialize};
 use std::collections::HashMap;
 
+use super::ethereum::pyth_pulse::SubscriptionParams;
+
 #[async_trait]
 pub trait UpdateChainPrices {
     async fn update_price_feeds(
@@ -16,7 +18,8 @@ pub trait UpdateChainPrices {
 
 #[async_trait]
 pub trait ReadChainSubscriptions {
-    async fn get_active_subscriptions(&self) -> Result<HashMap<SubscriptionId, Subscription>>;
+    async fn get_active_subscriptions(&self)
+        -> Result<HashMap<SubscriptionId, SubscriptionParams>>;
     async fn subscribe_to_subscription_events(&self) -> Result<()>; // TODO: return a stream
 }
 
@@ -26,11 +29,11 @@ pub trait ReadPythPrices {
     async fn subscribe_to_price_updates(&self, feed_ids: &[PriceId]) -> Result<()>; // TODO: return a stream
 }
 
-// TODO: find a different home for these
+// TODO: find a different home for these (public SDK)
 
 pub type PriceId = [u8; 32];
 
-pub type SubscriptionId = u64;
+pub type SubscriptionId = U256;
 
 #[derive(Debug, Clone, Serialize, Deserialize)]
 pub struct Price {
@@ -39,24 +42,3 @@ pub struct Price {
     pub expo: i32,
     pub publish_time: u64,
 }
-
-#[derive(Debug, Clone, Serialize, Deserialize)]
-pub struct Subscription {
-    pub id: SubscriptionId,
-    pub price_ids: Vec<PriceId>,
-    pub manager: Address,
-    pub is_active: bool,
-    pub update_criteria: UpdateCriteria,
-    pub last_updated_at: u64,
-    pub balance: U256,
-}
-
-#[derive(Debug, Clone, Serialize, Deserialize)]
-pub struct UpdateCriteria {
-    pub update_on_heartbeat: bool,
-    pub heartbeat_seconds: u32,
-    pub update_on_deviation: bool,
-    pub deviation_threshold_bps: u32,
-}
-
-pub struct SubscriptionEvent;

+ 3 - 3
apps/argus/src/api.rs

@@ -22,7 +22,7 @@ mod live;
 mod metrics;
 mod ready;
 
-pub type ChainId = String;
+pub type ChainName = String;
 
 #[derive(Clone, Debug, Hash, PartialEq, Eq, EncodeLabelSet)]
 pub struct RequestLabel {
@@ -64,8 +64,8 @@ impl ApiState {
 /// The state of the service for a single blockchain.
 #[derive(Clone)]
 pub struct BlockchainState {
-    /// The chain id for this blockchain, useful for logging
-    pub id: ChainId,
+    /// The human friendly name for this blockchain, useful for logging
+    pub name: ChainName,
     /// The BlockStatus of the block that is considered to be confirmed on the blockchain.
     /// For eg., Finalized, Safe
     pub confirmed_block_status: BlockStatus,

+ 84 - 94
apps/argus/src/command/run.rs

@@ -1,35 +1,24 @@
 use {
     crate::{
-        api::{self, BlockchainState, ChainId},
+        api::{self, BlockchainState, ChainName},
         config::{Config, EthereumConfig, RunOptions},
         keeper::{self, keeper_metrics::KeeperMetrics},
     },
     anyhow::{anyhow, Error, Result},
     axum::Router,
-    ethers::{middleware::Middleware, types::BlockNumber},
-    fortuna::eth_utils::traced_client::{RpcMetrics, TracedClient},
+    fortuna::eth_utils::traced_client::RpcMetrics,
     futures::future::join_all,
-    prometheus_client::{
-        encoding::EncodeLabelSet,
-        metrics::{family::Family, gauge::Gauge},
-        registry::Registry,
-    },
-    std::{
-        collections::HashMap,
-        net::SocketAddr,
-        sync::Arc,
-        time::{Duration, SystemTime, UNIX_EPOCH},
-    },
+    prometheus_client::{encoding::EncodeLabelSet, registry::Registry},
+    std::{collections::HashMap, net::SocketAddr, sync::Arc},
     tokio::{
         spawn,
         sync::{watch, RwLock},
-        time,
     },
     tower_http::cors::CorsLayer,
 };
 
 /// Track metrics in this interval
-const TRACK_INTERVAL: Duration = Duration::from_secs(10);
+// const TRACK_INTERVAL: Duration = Duration::from_secs(10);
 
 pub async fn run_api(
     socket_addr: SocketAddr,
@@ -111,7 +100,7 @@ pub async fn run(opts: &RunOptions) -> Result<()> {
     }
     let states = join_all(tasks).await;
 
-    let mut chains: HashMap<ChainId, BlockchainState> = HashMap::new();
+    let mut chains: HashMap<ChainName, BlockchainState> = HashMap::new();
     for result in states {
         let (chain_id, state) = result?;
 
@@ -153,11 +142,12 @@ pub async fn run(opts: &RunOptions) -> Result<()> {
     }
 
     // Spawn a thread to track latest block lag. This helps us know if the rpc is up and updated with the latest block.
-    spawn(track_block_timestamp_lag(
-        config,
-        metrics_registry.clone(),
-        rpc_metrics.clone(),
-    ));
+    // TODO: turn this into an actor.
+    // spawn(track_block_timestamp_lag(
+    //     config,
+    //     metrics_registry.clone(),
+    //     rpc_metrics.clone(),
+    // ));
 
     run_api(opts.addr, metrics_registry, rx_exit).await?;
 
@@ -165,11 +155,11 @@ pub async fn run(opts: &RunOptions) -> Result<()> {
 }
 
 async fn setup_chain_state(
-    chain_id: &ChainId,
+    chain_id: &ChainName,
     chain_config: &EthereumConfig,
 ) -> Result<BlockchainState> {
     let state = BlockchainState {
-        id: chain_id.clone(),
+        name: chain_id.clone(),
         confirmed_block_status: chain_config.confirmed_block_status,
     };
     Ok(state)
@@ -180,73 +170,73 @@ pub struct ChainLabel {
     pub chain_id: String,
 }
 
-#[tracing::instrument(name = "block_timestamp_lag", skip_all, fields(chain_id = chain_id))]
-pub async fn check_block_timestamp_lag(
-    chain_id: String,
-    chain_config: EthereumConfig,
-    metrics: Family<ChainLabel, Gauge>,
-    rpc_metrics: Arc<RpcMetrics>,
-) {
-    let provider =
-        match TracedClient::new(chain_id.clone(), &chain_config.geth_rpc_addr, rpc_metrics) {
-            Ok(r) => r,
-            Err(e) => {
-                tracing::error!("Failed to create provider for chain id - {:?}", e);
-                return;
-            }
-        };
-
-    const INF_LAG: i64 = 1000000; // value that definitely triggers an alert
-    let lag = match provider.get_block(BlockNumber::Latest).await {
-        Ok(block) => match block {
-            Some(block) => {
-                let block_timestamp = block.timestamp;
-                let server_timestamp = SystemTime::now()
-                    .duration_since(UNIX_EPOCH)
-                    .unwrap()
-                    .as_secs();
-                let lag: i64 = (server_timestamp as i64) - (block_timestamp.as_u64() as i64);
-                lag
-            }
-            None => {
-                tracing::error!("Block is None");
-                INF_LAG
-            }
-        },
-        Err(e) => {
-            tracing::error!("Failed to get block - {:?}", e);
-            INF_LAG
-        }
-    };
-    metrics
-        .get_or_create(&ChainLabel {
-            chain_id: chain_id.clone(),
-        })
-        .set(lag);
-}
-
-/// Tracks the difference between the server timestamp and the latest block timestamp for each chain
-pub async fn track_block_timestamp_lag(
-    config: Config,
-    metrics_registry: Arc<RwLock<Registry>>,
-    rpc_metrics: Arc<RpcMetrics>,
-) {
-    let metrics = Family::<ChainLabel, Gauge>::default();
-    metrics_registry.write().await.register(
-        "block_timestamp_lag",
-        "The difference between server timestamp and latest block timestamp",
-        metrics.clone(),
-    );
-    loop {
-        for (chain_id, chain_config) in &config.chains {
-            spawn(check_block_timestamp_lag(
-                chain_id.clone(),
-                chain_config.clone(),
-                metrics.clone(),
-                rpc_metrics.clone(),
-            ));
-        }
-
-        time::sleep(TRACK_INTERVAL).await;
-    }
-}
+// #[tracing::instrument(name = "block_timestamp_lag", skip_all, fields(chain_id = chain_id))]
+// pub async fn check_block_timestamp_lag(
+//     chain_id: String,
+//     chain_config: EthereumConfig,
+//     metrics: Family<ChainLabel, Gauge>,
+//     rpc_metrics: Arc<RpcMetrics>,
+// ) {
+//     let provider =
+//         match TracedClient::new(chain_id.clone(), &chain_config.geth_rpc_addr, rpc_metrics) {
+//             Ok(r) => r,
+//             Err(e) => {
+//                 tracing::error!("Failed to create provider for chain id - {:?}", e);
+//                 return;
+//             }
+//         };
+
+//     const INF_LAG: i64 = 1000000; // value that definitely triggers an alert
+//     let lag = match provider.get_block(BlockNumber::Latest).await {
+//         Ok(block) => match block {
+//             Some(block) => {
+//                 let block_timestamp = block.timestamp;
+//                 let server_timestamp = SystemTime::now()
+//                     .duration_since(UNIX_EPOCH)
+//                     .unwrap()
+//                     .as_secs();
+//                 let lag: i64 = (server_timestamp as i64) - (block_timestamp.as_u64() as i64);
+//                 lag
+//             }
+//             None => {
+//                 tracing::error!("Block is None");
+//                 INF_LAG
+//             }
+//         },
+//         Err(e) => {
+//             tracing::error!("Failed to get block - {:?}", e);
+//             INF_LAG
+//         }
+//     };
+//     metrics
+//         .get_or_create(&ChainLabel {
+//             chain_id: chain_id.clone(),
+//         })
+//         .set(lag);
+// }
+
+// /// Tracks the difference between the server timestamp and the latest block timestamp for each chain
+// pub async fn track_block_timestamp_lag(
+//     config: Config,
+//     metrics_registry: Arc<RwLock<Registry>>,
+//     rpc_metrics: Arc<RpcMetrics>,
+// ) {
+//     let metrics = Family::<ChainLabel, Gauge>::default();
+//     metrics_registry.write().await.register(
+//         "block_timestamp_lag",
+//         "The difference between server timestamp and latest block timestamp",
+//         metrics.clone(),
+//     );
+//     loop {
+//         for (chain_id, chain_config) in &config.chains {
+//             spawn(check_block_timestamp_lag(
+//                 chain_id.clone(),
+//                 chain_config.clone(),
+//                 metrics.clone(),
+//                 rpc_metrics.clone(),
+//             ));
+//         }
+
+//         time::sleep(TRACK_INTERVAL).await;
+//     }
+// }

+ 7 - 12
apps/argus/src/config.rs

@@ -1,6 +1,6 @@
 pub use run::RunOptions;
 use {
-    crate::{adapters::ethereum::BlockStatus, api::ChainId},
+    crate::{adapters::ethereum::BlockStatus, api::ChainName},
     anyhow::{anyhow, Result},
     clap::{crate_authors, crate_description, crate_name, crate_version, Args, Parser},
     ethers::types::Address,
@@ -36,7 +36,7 @@ pub struct ConfigOptions {
 
 #[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
 pub struct Config {
-    pub chains: HashMap<ChainId, EthereumConfig>,
+    pub chains: HashMap<ChainName, EthereumConfig>,
     pub keeper: KeeperConfig,
 }
 
@@ -44,13 +44,15 @@ impl Config {
     pub fn load(path: &str) -> Result<Config> {
         // Open and read the YAML file
         // TODO: the default serde deserialization doesn't enforce unique keys
-        let yaml_content = fs::read_to_string(path)?;
-        let config: Config = serde_yaml::from_str(&yaml_content)?;
+        let yaml_content = fs::read_to_string(path)
+            .map_err(|e| anyhow!("Failed to read config file '{}': {}", path, e))?;
+        let config: Config = serde_yaml::from_str(&yaml_content)
+            .map_err(|e| anyhow!("Failed to parse config file '{}': {}", path, e))?;
 
         Ok(config)
     }
 
-    pub fn get_chain_config(&self, chain_id: &ChainId) -> Result<EthereumConfig> {
+    pub fn get_chain_config(&self, chain_id: &ChainName) -> Result<EthereumConfig> {
         self.chains.get(chain_id).cloned().ok_or(anyhow!(
             "Could not find chain id {} in the configuration",
             &chain_id
@@ -79,19 +81,12 @@ pub struct EthereumConfig {
     #[serde(default)]
     pub legacy_tx: bool,
 
-    /// The gas limit to use for entropy callback transactions.
-    pub gas_limit: u64,
-
     /// The percentage multiplier to apply to priority fee estimates (100 = no change, e.g. 150 = 150% of base fee)
     pub priority_fee_multiplier_pct: u64,
 
     /// The escalation policy governs how the gas limit and fee are increased during backoff retries.
     #[serde(default)]
     pub escalation_policy: EscalationPolicyConfig,
-
-    /// How much the provider charges for a request on this chain.
-    #[serde(default)]
-    pub fee: u128,
 }
 
 #[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]

+ 21 - 18
apps/argus/src/keeper.rs

@@ -23,7 +23,7 @@ use {
 
 pub(crate) mod keeper_metrics;
 
-#[tracing::instrument(name = "keeper", skip_all, fields(chain_id = chain_state.id))]
+#[tracing::instrument(name = "keeper", skip_all, fields(chain_id = chain_state.name))]
 pub async fn run_keeper_for_chain(
     private_key: String,
     chain_eth_config: EthereumConfig,
@@ -37,17 +37,20 @@ pub async fn run_keeper_for_chain(
         InstrumentedSignablePythContract::from_config(
             &chain_eth_config,
             &private_key,
-            chain_state.id.clone(),
+            chain_state.name.clone(),
             rpc_metrics.clone(),
         )
         .await
-        .expect("Chain config should be valid"),
+        .expect(&format!(
+            "Failed to create InstrumentedSignablePythContract from config for chain {}",
+            chain_state.name
+        )),
     );
 
     let keeper_address = contract.wallet().address();
 
     tracing::info!(
-        chain_id = chain_state.id,
+        chain_id = chain_state.name,
         keeper_address = %keeper_address,
         "Keeper address"
     );
@@ -67,10 +70,10 @@ pub async fn run_keeper_for_chain(
     };
 
     let (subscription_listener, _) = Actor::spawn(
-        Some(format!("SubscriptionListener-{}", chain_state.id)),
+        Some(format!("SubscriptionListener-{}", chain_state.name)),
         SubscriptionListener,
         (
-            chain_state.id.clone(),
+            chain_state.name.clone(),
             contract.clone() as Arc<dyn ReadChainSubscriptions + Send + Sync>,
             subscription_poll_interval,
         ),
@@ -79,21 +82,21 @@ pub async fn run_keeper_for_chain(
     .expect("Failed to spawn SubscriptionListener actor");
 
     let (pyth_price_listener, _) = Actor::spawn(
-        Some(format!("PythPriceListener-{}", chain_state.id)),
+        Some(format!("PythPriceListener-{}", chain_state.name)),
         PythPriceListener,
         hermes_client.clone(),
     )
     .await
     .expect(&format!(
         "Failed to spawn PythPriceListener-{} actor",
-        chain_state.id
+        chain_state.name
     ));
 
     let (chain_price_listener, _) = Actor::spawn(
-        Some(format!("ChainPriceListener-{}", chain_state.id)),
+        Some(format!("ChainPriceListener-{}", chain_state.name)),
         ChainPriceListener,
         (
-            chain_state.id.clone(),
+            chain_state.name.clone(),
             contract.clone(),
             chain_price_poll_interval,
         ),
@@ -101,14 +104,14 @@ pub async fn run_keeper_for_chain(
     .await
     .expect(&format!(
         "Failed to spawn ChainPriceListener-{} actor",
-        chain_state.id
+        chain_state.name
     ));
 
     let (price_pusher, _) = Actor::spawn(
-        Some(format!("PricePusher-{}", chain_state.id)),
+        Some(format!("PricePusher-{}", chain_state.name)),
         PricePusher,
         (
-            chain_state.id.clone(),
+            chain_state.name.clone(),
             contract.clone(),
             hermes_client.clone(),
             backoff_policy,
@@ -117,14 +120,14 @@ pub async fn run_keeper_for_chain(
     .await
     .expect(&format!(
         "Failed to spawn PricePusher-{} actor",
-        chain_state.id
+        chain_state.name
     ));
 
     let (_controller, _) = Actor::spawn(
-        Some(format!("Controller-{}", chain_state.id)),
+        Some(format!("Controller-{}", chain_state.name)),
         Controller,
         (
-            chain_state.id.clone(),
+            chain_state.name.clone(),
             subscription_listener,
             pyth_price_listener,
             chain_price_listener,
@@ -135,8 +138,8 @@ pub async fn run_keeper_for_chain(
     .await
     .expect(&format!(
         "Failed to spawn Controller-{} actor",
-        chain_state.id
+        chain_state.name
     ));
 
-    tracing::info!(chain_id = chain_state.id, "Keeper actors started");
+    tracing::info!(chain_id = chain_state.name, "Keeper actors started");
 }