diff --git a/crates/node/rpc/src/health.rs b/crates/node/rpc/src/health.rs index e99a8328be..98ba9d105c 100644 --- a/crates/node/rpc/src/health.rs +++ b/crates/node/rpc/src/health.rs @@ -6,7 +6,7 @@ use jsonrpsee::{ use rollup_boost::Health; use tokio::sync::{mpsc, oneshot}; -use crate::jsonrpsee::HealthzApiServer; +use crate::jsonrpsee::{HealthzApiServer, RollupBoostHealthzApiServer}; /// Key for the rollup boost health status. /// +----------------+-------------------------------+--------------------------------------+-------------------------------+ @@ -55,6 +55,11 @@ impl From for RollupBoostHealth { pub struct HealthzResponse { /// The application version. pub version: String, +} + +/// A healthcheck response for the rollup boost health. +#[derive(Debug, Clone, serde::Deserialize, serde::Serialize)] +pub struct RollupBoostHealthzResponse { /// The rollup boost health. pub rollup_boost_health: RollupBoostHealth, } @@ -67,7 +72,7 @@ pub struct RollupBoostHealthQuery { } /// The healthz rpc server. -#[derive(Debug)] +#[derive(Debug, Clone)] pub struct HealthzRpc { /// The rollup boost health. pub rollup_boost_health: mpsc::Sender, @@ -83,6 +88,13 @@ impl HealthzRpc { #[async_trait] impl HealthzApiServer for HealthzRpc { async fn healthz(&self) -> RpcResult { + Ok(HealthzResponse { version: env!("CARGO_PKG_VERSION").to_string() }) + } +} + +#[async_trait] +impl RollupBoostHealthzApiServer for HealthzRpc { + async fn rollup_boost_healthz(&self) -> RpcResult { let (tx, rx) = oneshot::channel(); self.rollup_boost_health @@ -93,6 +105,6 @@ impl HealthzApiServer for HealthzRpc { let rollup_boost_health = rx.await.map_err(|_| ErrorObject::from(ErrorCode::InternalError))?; - Ok(HealthzResponse { version: env!("CARGO_PKG_VERSION").to_string(), rollup_boost_health }) + Ok(RollupBoostHealthzResponse { rollup_boost_health }) } } diff --git a/crates/node/rpc/src/jsonrpsee.rs b/crates/node/rpc/src/jsonrpsee.rs index dd90937d06..890dcefeba 100644 --- a/crates/node/rpc/src/jsonrpsee.rs +++ b/crates/node/rpc/src/jsonrpsee.rs @@ -1,6 +1,9 @@ //! The Optimism RPC API using `jsonrpsee` -use crate::{OutputResponse, SafeHeadResponse, health::HealthzResponse}; +use crate::{ + OutputResponse, SafeHeadResponse, + health::{HealthzResponse, RollupBoostHealthzResponse}, +}; use alloy_eips::BlockNumberOrTag; use alloy_primitives::B256; use core::net::IpAddr; @@ -220,3 +223,12 @@ pub trait HealthzApi { #[method(name = "healthz")] async fn healthz(&self) -> RpcResult; } + +/// The rollup boost health namespace. +#[cfg_attr(not(feature = "client"), rpc(server, namespace = "kona-rollup-boost"))] +#[cfg_attr(feature = "client", rpc(server, client, namespace = "kona-rollup-boost"))] +pub trait RollupBoostHealthzApi { + /// Gets the rollup boost health. + #[method(name = "healthz")] + async fn rollup_boost_healthz(&self) -> RpcResult; +} diff --git a/crates/node/rpc/src/lib.rs b/crates/node/rpc/src/lib.rs index de4e851d9f..108c5e56ea 100644 --- a/crates/node/rpc/src/lib.rs +++ b/crates/node/rpc/src/lib.rs @@ -35,7 +35,7 @@ pub use dev::DevEngineRpc; mod jsonrpsee; pub use jsonrpsee::{ AdminApiServer, DevEngineApiServer, HealthzApiServer, MinerApiExtServer, OpAdminApiServer, - OpP2PApiServer, RollupNodeApiServer, WsServer, + OpP2PApiServer, RollupBoostHealthzApiServer, RollupNodeApiServer, WsServer, }; mod rollup; @@ -48,4 +48,7 @@ mod ws; pub use ws::WsRPC; mod health; -pub use health::{HealthzResponse, HealthzRpc, RollupBoostHealth, RollupBoostHealthQuery}; +pub use health::{ + HealthzResponse, HealthzRpc, RollupBoostHealth, RollupBoostHealthQuery, + RollupBoostHealthzResponse, +}; diff --git a/crates/node/service/src/actors/rpc.rs b/crates/node/service/src/actors/rpc.rs index b6f33699e2..9b8d02cd5b 100644 --- a/crates/node/service/src/actors/rpc.rs +++ b/crates/node/service/src/actors/rpc.rs @@ -6,7 +6,7 @@ use kona_gossip::P2pRpcRequest; use kona_rpc::{ AdminApiServer, AdminRpc, DevEngineApiServer, DevEngineRpc, HealthzApiServer, HealthzRpc, NetworkAdminQuery, OpP2PApiServer, RollupBoostAdminQuery, RollupBoostHealthQuery, - RollupNodeApiServer, SequencerAdminAPIClient, WsRPC, WsServer, + RollupBoostHealthzApiServer, RollupNodeApiServer, SequencerAdminAPIClient, WsRPC, WsServer, }; use std::time::Duration; @@ -93,8 +93,11 @@ async fn launch( ) -> Result { let middleware = tower::ServiceBuilder::new() .layer( - ProxyGetRequestLayer::new([("/healthz", "healthz")]) - .expect("Critical: Failed to build GET method proxy"), + ProxyGetRequestLayer::new([ + ("/healthz", "healthz"), + ("/kona-rollup-boost/healthz", "kona-rollup-boost_healthz"), + ]) + .expect("Critical: Failed to build GET method proxy"), ) .timeout(Duration::from_secs(2)); let server = Server::builder().set_http_middleware(middleware).build(config.socket).await?; @@ -128,7 +131,9 @@ impl NodeActor for RpcActor { ) -> Result<(), Self::Error> { let mut modules = RpcModule::new(()); - modules.merge(HealthzRpc::new(rollup_boost_health).into_rpc())?; + let healthz_rpc = HealthzRpc::new(rollup_boost_health); + modules.merge(HealthzApiServer::into_rpc(healthz_rpc.clone()))?; + modules.merge(RollupBoostHealthzApiServer::into_rpc(healthz_rpc))?; // Build the p2p rpc module. modules.merge(P2pRpc::new(p2p_network).into_rpc())?;