-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add dummy health check tasks for state keeper and eth sender
- Loading branch information
1 parent
3d7e82c
commit de3a5e1
Showing
5 changed files
with
184 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
use async_trait::async_trait; | ||
use serde::{Deserialize, Serialize}; | ||
use zksync_dal::{ConnectionPool, Core, CoreDal}; | ||
use zksync_health_check::{Health, HealthStatus, HealthUpdater}; | ||
|
||
use crate::periodic_job::PeriodicJob; | ||
|
||
#[derive(Debug, Serialize, Deserialize)] | ||
pub struct EthSenderInfo { | ||
failed_l1_txns: Option<()>, | ||
last_created_commit_batch: Option<()>, | ||
last_created_prove_batch: Option<()>, | ||
last_created_execute_batch: Option<()>, | ||
last_executed_commit_batch: Option<()>, | ||
last_executed_prove_batch: Option<()>, | ||
last_executed_execute_batch: Option<()>, | ||
current_nonce: Option<()>, | ||
latest_operator_nonce: Option<()>, | ||
} | ||
|
||
impl From<EthSenderInfo> for Health { | ||
fn from(details: EthSenderInfo) -> Self { | ||
Self::from(HealthStatus::Ready).with_details(details) | ||
} | ||
} | ||
|
||
#[derive(Debug)] | ||
pub struct EthSenderHealthTask { | ||
pub connection_pool: ConnectionPool<Core>, | ||
pub eth_sender_health_updater: HealthUpdater, | ||
} | ||
|
||
impl EthSenderHealthTask { | ||
pub const POLLING_INTERVAL_MS: u64 = 10_000; | ||
} | ||
|
||
#[async_trait] | ||
impl PeriodicJob for EthSenderHealthTask { | ||
const SERVICE_NAME: &'static str = "EthSenderHealth"; | ||
|
||
async fn run_routine_task(&mut self) -> anyhow::Result<()> { | ||
let mut conn = self.connection_pool.connection().await.unwrap(); | ||
let _last_migration = conn.system_dal().get_last_migration().await.unwrap(); | ||
|
||
self.eth_sender_health_updater.update( | ||
EthSenderInfo { | ||
failed_l1_txns: None, | ||
last_created_commit_batch: None, | ||
last_created_prove_batch: None, | ||
last_created_execute_batch: None, | ||
last_executed_commit_batch: None, | ||
last_executed_prove_batch: None, | ||
last_executed_execute_batch: None, | ||
current_nonce: None, | ||
latest_operator_nonce: None, | ||
} | ||
.into(), | ||
); | ||
Ok(()) | ||
} | ||
|
||
fn polling_interval_ms(&self) -> u64 { | ||
Self::POLLING_INTERVAL_MS | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
pub mod blocks_state_reporter; | ||
pub mod database; | ||
pub mod eth_sender; | ||
mod metrics; | ||
pub mod periodic_job; | ||
pub mod state_keeper; | ||
pub mod version; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
use async_trait::async_trait; | ||
use serde::{Deserialize, Serialize}; | ||
use zksync_dal::{ConnectionPool, Core, CoreDal}; | ||
use zksync_health_check::{Health, HealthStatus, HealthUpdater}; | ||
|
||
use crate::periodic_job::PeriodicJob; | ||
|
||
#[derive(Debug, Serialize, Deserialize)] | ||
pub struct StateKeeperInfo { | ||
last_miniblock_protocol_upgrade: Option<()>, | ||
last_miniblock: Option<()>, | ||
batch_number: Option<()>, | ||
} | ||
|
||
impl From<StateKeeperInfo> for Health { | ||
fn from(details: StateKeeperInfo) -> Self { | ||
Self::from(HealthStatus::Ready).with_details(details) | ||
} | ||
} | ||
|
||
#[derive(Debug)] | ||
pub struct StateKeeperHealthTask { | ||
pub connection_pool: ConnectionPool<Core>, | ||
pub state_keeper_health_updater: HealthUpdater, | ||
} | ||
|
||
impl StateKeeperHealthTask { | ||
pub const POLLING_INTERVAL_MS: u64 = 10_000; | ||
} | ||
|
||
#[async_trait] | ||
impl PeriodicJob for StateKeeperHealthTask { | ||
const SERVICE_NAME: &'static str = "StateKeeperHealth"; | ||
|
||
async fn run_routine_task(&mut self) -> anyhow::Result<()> { | ||
let mut conn = self.connection_pool.connection().await.unwrap(); | ||
let _last_migration = conn.system_dal().get_last_migration().await.unwrap(); | ||
|
||
self.state_keeper_health_updater.update( | ||
StateKeeperInfo { | ||
last_miniblock_protocol_upgrade: None, | ||
last_miniblock: None, | ||
batch_number: None, | ||
} | ||
.into(), | ||
); | ||
Ok(()) | ||
} | ||
|
||
fn polling_interval_ms(&self) -> u64 { | ||
Self::POLLING_INTERVAL_MS | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters