From 2cba04774b1c72f31b55e32a20947b80a4e3f087 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Thu, 23 Mar 2023 13:51:29 +0100 Subject: [PATCH] chore(rpc): add traces for server start (#1925) --- Cargo.lock | 1 + crates/rpc/ipc/src/server/mod.rs | 5 +++++ crates/rpc/rpc-builder/Cargo.toml | 3 +++ crates/rpc/rpc-builder/src/lib.rs | 9 +++++++++ 4 files changed, 18 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index 9fea3582ca..d4f952dbb1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5091,6 +5091,7 @@ dependencies = [ "tokio", "tower", "tower-http", + "tracing", ] [[package]] diff --git a/crates/rpc/ipc/src/server/mod.rs b/crates/rpc/ipc/src/server/mod.rs index f4718fd5cc..35cfdd582a 100644 --- a/crates/rpc/ipc/src/server/mod.rs +++ b/crates/rpc/ipc/src/server/mod.rs @@ -47,6 +47,11 @@ pub struct IpcServer { } impl IpcServer { + /// Returns the configured [Endpoint] + pub fn endpoint(&self) -> &Endpoint { + &self.endpoint + } + /// Start responding to connections requests. /// /// This will run on the tokio runtime until the server is stopped or the ServerHandle is diff --git a/crates/rpc/rpc-builder/Cargo.toml b/crates/rpc/rpc-builder/Cargo.toml index 465bdc3510..2730dd1e6f 100644 --- a/crates/rpc/rpc-builder/Cargo.toml +++ b/crates/rpc/rpc-builder/Cargo.toml @@ -18,14 +18,17 @@ reth-rpc-types = { path = "../rpc-types" } reth-tasks = { path = "../../tasks" } reth-transaction-pool = { path = "../../transaction-pool" } +# rpc/net jsonrpsee = { version = "0.16", features = ["server"] } tower-http = { version = "0.3", features = ["full"] } tower = { version = "0.4", features = ["full"] } hyper = "0.14" +# misc strum = { version = "0.24", features = ["derive"] } serde = { version = "1.0", features = ["derive"] } thiserror = "1.0" +tracing = "0.1" [dev-dependencies] reth-tracing = { path = "../../tracing" } diff --git a/crates/rpc/rpc-builder/src/lib.rs b/crates/rpc/rpc-builder/src/lib.rs index 1dab50a005..b529bbac71 100644 --- a/crates/rpc/rpc-builder/src/lib.rs +++ b/crates/rpc/rpc-builder/src/lib.rs @@ -75,6 +75,8 @@ use strum::{AsRefStr, EnumString, EnumVariantNames, ParseError, VariantNames}; use tower::layer::util::{Identity, Stack}; use tower_http::cors::CorsLayer; +use tracing::{instrument, trace}; + pub use jsonrpsee::server::ServerBuilder; pub use reth_ipc::server::{Builder as IpcServerBuilder, Endpoint}; @@ -983,14 +985,21 @@ impl RpcServer { self.ws_local_addr } + /// Returns the [`Endpoint`] of the ipc server if started. + pub fn ipc_endpoint(&self) -> Option<&Endpoint> { + self.ipc.as_ref().map(|ipc| ipc.endpoint()) + } + /// Starts the configured server by spawning the servers on the tokio runtime. /// /// This returns an [RpcServerHandle] that's connected to the server task(s) until the server is /// stopped or the [RpcServerHandle] is dropped. + #[instrument(name = "start", skip_all, fields(http = ?self.http_local_addr, ws = ?self.ws_local_addr, ipc = ?self.ipc_endpoint().map(|ipc|ipc.path())), target = "rpc", level = "TRACE")] pub async fn start( self, modules: TransportRpcModules<()>, ) -> Result { + trace!(target: "rpc", "staring RPC server"); let TransportRpcModules { http, ws, ipc } = modules; let mut handle = RpcServerHandle { http_local_addr: self.http_local_addr,