From e11d792e2eb48e73977b94ccddd1034f01399e82 Mon Sep 17 00:00:00 2001 From: init4samwise Date: Sun, 15 Feb 2026 03:15:32 +0000 Subject: [PATCH] feat(rpc): add signet_networkStatus endpoint (ENG-479) Adds a new signet_networkStatus RPC endpoint that returns Signet-specific network information: - chain_id: The Signet rollup chain ID - genesis: The genesis block hash (block 0) - head: The current head block hash - headNumber: The current head block number This addresses the TODOs from the original SignetNoopNetwork implementation which returned Default::default() for these values. The new endpoint exposes the actual Signet network state rather than delegating to the host network. The endpoint is exposed as signet_networkStatus and returns a JSON object with camelCase field names. Closes ENG-479 --- crates/rpc/src/lib.rs | 2 +- crates/rpc/src/signet/endpoints.rs | 58 ++++++++++++++++++++++++++++++ crates/rpc/src/signet/mod.rs | 7 +++- 3 files changed, 65 insertions(+), 2 deletions(-) diff --git a/crates/rpc/src/lib.rs b/crates/rpc/src/lib.rs index 0a5ff8a..980dbcb 100644 --- a/crates/rpc/src/lib.rs +++ b/crates/rpc/src/lib.rs @@ -63,7 +63,7 @@ mod eth; pub use eth::{CallErrorData, EthError, eth}; mod signet; -pub use signet::{error::SignetError, signet}; +pub use signet::{SignetNetworkStatus, error::SignetError, signet}; mod inspect; pub use inspect::inspect; diff --git a/crates/rpc/src/signet/endpoints.rs b/crates/rpc/src/signet/endpoints.rs index 4abda48..8035796 100644 --- a/crates/rpc/src/signet/endpoints.rs +++ b/crates/rpc/src/signet/endpoints.rs @@ -4,13 +4,71 @@ use crate::{ utils::{await_handler, response_tri}, }; use ajj::{HandlerCtx, ResponsePayload}; +use alloy::{eips::BlockId, primitives::B256}; +use reth::providers::{BlockHashReader, BlockNumReader}; use reth_node_api::FullNodeComponents; +use serde::Serialize; use signet_bundle::{SignetBundleDriver, SignetCallBundle, SignetCallBundleResponse}; use signet_node_types::Pnt; use signet_types::SignedOrder; use std::time::Duration; use tokio::select; +/// Signet network status information. +/// +/// This provides Signet-specific network status, as opposed to the host +/// network status which would be returned by `eth_protocolVersion`. +#[derive(Debug, Clone, Serialize)] +#[serde(rename_all = "camelCase")] +pub struct SignetNetworkStatus { + /// The Signet chain ID. + pub chain_id: u64, + /// The genesis block hash. + pub genesis: B256, + /// The current head block hash. + pub head: B256, + /// The current head block number. + pub head_number: u64, +} + +/// Returns the Signet network status including genesis and head block info. +/// +/// This endpoint provides Signet-specific network information that reflects +/// the rollup's state rather than the underlying host network. +pub(super) async fn network_status( + hctx: HandlerCtx, + ctx: RpcCtx, +) -> Result +where + Host: FullNodeComponents, + Signet: Pnt, +{ + let task = async move { + let provider = ctx.signet().provider(); + + // Get the genesis block hash (block 0) + let genesis = provider + .block_hash(0) + .map_err(|e| e.to_string())? + .ok_or_else(|| "genesis block hash not found".to_string())?; + + // Get the current head block number and hash + let head_number = provider.last_block_number().map_err(|e| e.to_string())?; + + let head = provider + .block_hash(head_number) + .map_err(|e| e.to_string())? + .ok_or_else(|| "head block hash not found".to_string())?; + + // Get the chain ID from constants + let chain_id = ctx.signet().constants().ru_chain_id(); + + Ok(SignetNetworkStatus { chain_id, genesis, head, head_number }) + }; + + await_handler!(@option hctx.spawn_blocking(task)) +} + pub(super) async fn send_order( hctx: HandlerCtx, order: SignedOrder, diff --git a/crates/rpc/src/signet/mod.rs b/crates/rpc/src/signet/mod.rs index c882000..26b78db 100644 --- a/crates/rpc/src/signet/mod.rs +++ b/crates/rpc/src/signet/mod.rs @@ -5,6 +5,8 @@ use endpoints::*; pub(crate) mod error; +pub use endpoints::SignetNetworkStatus; + use crate::ctx::RpcCtx; use reth_node_api::FullNodeComponents; use signet_node_types::Pnt; @@ -15,5 +17,8 @@ where Host: FullNodeComponents, Signet: Pnt, { - ajj::Router::new().route("sendOrder", send_order).route("callBundle", call_bundle) + ajj::Router::new() + .route("sendOrder", send_order) + .route("callBundle", call_bundle) + .route("networkStatus", network_status) }