From 9149462fa066f02fd18b4917cc8e61efbdb0aa11 Mon Sep 17 00:00:00 2001 From: Denys Zadorozhnyi Date: Fri, 30 Jun 2023 08:53:57 +0300 Subject: [PATCH] check pool box rate in pool health assessment; --- core/src/api.rs | 17 +++++++++-------- core/src/metrics.rs | 1 + core/src/monitor.rs | 7 +++++-- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/core/src/api.rs b/core/src/api.rs index a7d9bc2a..f79affa3 100644 --- a/core/src/api.rs +++ b/core/src/api.rs @@ -201,15 +201,16 @@ async fn pool_health(oracle_pool: Arc) -> Result) -> Result { let node_api = NodeApi::new(ORACLE_SECRETS.node_api_key.clone(), &ORACLE_CONFIG.node_url); let current_height = (node_api.node.current_block_height()? as u32).into(); - let pool_box_height = oracle_pool - .get_pool_box_source() - .get_pool_box()? - .get_box() - .creation_height - .into(); + let pool_box = &oracle_pool.get_pool_box_source().get_pool_box()?; + let pool_box_height = pool_box.get_box().creation_height.into(); let network_prefix = node_api.get_change_address()?.network(); - let pool_health = - check_pool_health(current_height, pool_box_height, oracle_pool, network_prefix)?; + let pool_health = check_pool_health( + current_height, + pool_box_height, + pool_box.rate(), + oracle_pool, + network_prefix, + )?; Ok(pool_health) } diff --git a/core/src/metrics.rs b/core/src/metrics.rs index e9c14143..0bfe7f51 100644 --- a/core/src/metrics.rs +++ b/core/src/metrics.rs @@ -283,6 +283,7 @@ pub fn update_metrics(oracle_pool: Arc) -> Result<(), anyhow::Error> let pool_health = check_pool_health( current_height, pool_box_height, + pool_box.rate(), oracle_pool.clone(), network_prefix, )?; diff --git a/core/src/monitor.rs b/core/src/monitor.rs index 47165ab2..3549f5f6 100644 --- a/core/src/monitor.rs +++ b/core/src/monitor.rs @@ -12,6 +12,7 @@ use crate::oracle_state::OraclePool; use crate::oracle_types::BlockHeight; use crate::oracle_types::EpochLength; use crate::oracle_types::MinDatapoints; +use crate::oracle_types::Rate; use crate::pool_config::POOL_CONFIG; #[derive(Debug, serde::Serialize, Copy, Clone)] @@ -52,6 +53,7 @@ pub struct PoolHealth { pub fn check_pool_health( current_height: BlockHeight, pool_box_height: BlockHeight, + pool_box_rate: Rate, oracle_pool: Arc, network_prefix: NetworkPrefix, ) -> Result { @@ -64,8 +66,9 @@ pub fn check_pool_health( .0 .into(); let acceptable_pool_box_delay_blocks = 3; - let is_healthy = - pool_box_height >= current_height - epoch_length - acceptable_pool_box_delay_blocks; + let is_healthy = pool_box_height >= current_height - epoch_length - acceptable_pool_box_delay_blocks + // on bootstrap pool box created with rate 0 + && pool_box_rate != 0; let total_oracle_token_count = oracle_pool.get_total_oracle_token_count()?; let all_oracles = get_all_oracle_boxes(oracle_pool, network_prefix)?; let active_oracles = get_active_oracle_boxes(&all_oracles, pool_box_height);