From 94c43a08c4273d681a9656790e4ed33d7176d36c Mon Sep 17 00:00:00 2001 From: jfldde <168934971+jfldde@users.noreply.github.com> Date: Wed, 6 Nov 2024 15:50:40 +0000 Subject: [PATCH] Da monitoring support (#47) * Monitoring config * Remove reorg_depth from config * fmt * Expose inner request method * Expose http client * lint * Add PARALLEL_PROOF_LIMIT to base_env --- src/citrea_config/bitcoin.rs | 17 +++++++++++++++++ src/citrea_config/rollup.rs | 3 +++ src/client.rs | 4 ++++ src/config/test_case.rs | 2 +- 4 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/citrea_config/bitcoin.rs b/src/citrea_config/bitcoin.rs index e4119ff..b69148b 100644 --- a/src/citrea_config/bitcoin.rs +++ b/src/citrea_config/bitcoin.rs @@ -1,5 +1,20 @@ use serde::{Deserialize, Serialize}; +impl Default for MonitoringConfig { + fn default() -> Self { + Self { + check_interval: 1, + history_limit: 100, + } + } +} + +#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)] +pub struct MonitoringConfig { + pub check_interval: u64, + pub history_limit: usize, +} + /// Runtime configuration for the DA service #[derive(Debug, Clone, PartialEq, Deserialize, Serialize)] pub struct BitcoinServiceConfig { @@ -16,4 +31,6 @@ pub struct BitcoinServiceConfig { // absolute path to the directory where the txs will be written to pub tx_backup_dir: String, + + pub monitoring: MonitoringConfig, } diff --git a/src/citrea_config/rollup.rs b/src/citrea_config/rollup.rs index 9213778..361c800 100644 --- a/src/citrea_config/rollup.rs +++ b/src/citrea_config/rollup.rs @@ -3,6 +3,7 @@ use std::path::PathBuf; use serde::{Deserialize, Serialize}; use tempfile::TempDir; +use super::bitcoin::MonitoringConfig; use crate::config::{BitcoinConfig, BitcoinServiceConfig}; /// Runner configuration. @@ -153,6 +154,7 @@ impl Default for FullNodeConfig { .into_path() .display() .to_string(), + monitoring: MonitoringConfig::default(), }, public_keys: RollupPublicKeys { sequencer_public_key: vec![ @@ -186,6 +188,7 @@ impl From for BitcoinServiceConfig { network: v.network, da_private_key: None, tx_backup_dir: String::new(), + monitoring: Default::default(), } } } diff --git a/src/client.rs b/src/client.rs index 8324c65..3df8210 100644 --- a/src/client.rs +++ b/src/client.rs @@ -26,6 +26,10 @@ impl Client { .build(host)?; Ok(Self { client }) } + + pub fn http_client(&self) -> &HttpClient { + &self.client + } } impl Client { diff --git a/src/config/test_case.rs b/src/config/test_case.rs index ea1784e..aee3dd6 100644 --- a/src/config/test_case.rs +++ b/src/config/test_case.rs @@ -15,7 +15,7 @@ pub struct TestCaseEnv { impl TestCaseEnv { // Base env that should apply to every test cases fn base_env() -> Vec<(&'static str, &'static str)> { - vec![("NO_COLOR", "1")] + vec![("NO_COLOR", "1"), ("PARALLEL_PROOF_LIMIT", "1")] } fn test_env(&self) -> Vec<(&'static str, &'static str)> {