From 2882991173d092ce9435d14103105e6a31314e02 Mon Sep 17 00:00:00 2001 From: Alessandro Mazza <121622391+alessandromazza98@users.noreply.github.com> Date: Fri, 14 Mar 2025 21:06:42 +0100 Subject: [PATCH] fix: add debug namespace to auth module in op-reth (#15048) --- Cargo.lock | 1 + crates/ethereum/node/src/node.rs | 2 +- crates/node/builder/src/rpc.rs | 10 +++++++--- crates/optimism/node/Cargo.toml | 1 + crates/optimism/node/src/node.rs | 12 ++++++++++-- 5 files changed, 20 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fdff412279..c0ccfd155b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8811,6 +8811,7 @@ dependencies = [ "reth-primitives-traits", "reth-provider", "reth-revm", + "reth-rpc-api", "reth-rpc-engine-api", "reth-rpc-eth-api", "reth-rpc-eth-types", diff --git a/crates/ethereum/node/src/node.rs b/crates/ethereum/node/src/node.rs index a53cb51aa1..4874090f7d 100644 --- a/crates/ethereum/node/src/node.rs +++ b/crates/ethereum/node/src/node.rs @@ -198,7 +198,7 @@ where ); self.inner - .launch_add_ons_with(ctx, move |modules, _| { + .launch_add_ons_with(ctx, move |modules, _, _| { modules.merge_if_module_configured( RethRpcModule::Flashbots, validation_api.into_rpc(), diff --git a/crates/node/builder/src/rpc.rs b/crates/node/builder/src/rpc.rs index 556b6e6147..b7ff85efed 100644 --- a/crates/node/builder/src/rpc.rs +++ b/crates/node/builder/src/rpc.rs @@ -448,7 +448,11 @@ where ext: F, ) -> eyre::Result> where - F: FnOnce(&mut TransportRpcModules, &mut AuthRpcModule) -> eyre::Result<()>, + F: FnOnce( + &mut TransportRpcModules, + &mut AuthRpcModule, + &mut RpcRegistry, + ) -> eyre::Result<()>, { let Self { eth_api_builder, engine_api_builder, hooks, .. } = self; @@ -505,7 +509,7 @@ where let RpcHooks { on_rpc_started, extend_rpc_modules } = hooks; - ext(ctx.modules, ctx.auth_module)?; + ext(ctx.modules, ctx.auth_module, ctx.registry)?; extend_rpc_modules.extend_rpc_modules(ctx)?; let server_config = config.rpc.rpc_server_config(); @@ -568,7 +572,7 @@ where type Handle = RpcHandle; async fn launch_add_ons(self, ctx: AddOnsContext<'_, N>) -> eyre::Result { - self.launch_add_ons_with(ctx, |_, _| Ok(())).await + self.launch_add_ons_with(ctx, |_, _, _| Ok(())).await } } diff --git a/crates/optimism/node/Cargo.toml b/crates/optimism/node/Cargo.toml index 7b04473aab..4955662f08 100644 --- a/crates/optimism/node/Cargo.toml +++ b/crates/optimism/node/Cargo.toml @@ -37,6 +37,7 @@ reth-tasks = { workspace = true, optional = true } reth-trie-common.workspace = true reth-node-core.workspace = true reth-rpc-engine-api.workspace = true +reth-rpc-api.workspace = true # op-reth reth-optimism-payload-builder.workspace = true diff --git a/crates/optimism/node/src/node.rs b/crates/optimism/node/src/node.rs index 2d32e8ea27..c9081d028f 100644 --- a/crates/optimism/node/src/node.rs +++ b/crates/optimism/node/src/node.rs @@ -42,6 +42,7 @@ use reth_optimism_rpc::{ }; use reth_optimism_txpool::{conditional::MaybeConditionalTransaction, OpPooledTx}; use reth_provider::{providers::ProviderFactoryBuilder, CanonStateSubscriptions, EthStorage}; +use reth_rpc_api::DebugApiServer; use reth_rpc_eth_api::ext::L2EthApiExtServer; use reth_rpc_eth_types::error::FromEvmError; use reth_rpc_server_types::RethRpcModule; @@ -309,8 +310,9 @@ where ctx.node.pool().clone(), ctx.node.provider().clone(), ); + rpc_add_ons - .launch_add_ons_with(ctx, move |modules, auth_modules| { + .launch_add_ons_with(ctx, move |modules, auth_modules, registry| { debug!(target: "reth::cli", "Installing debug payload witness rpc endpoint"); modules.merge_if_module_configured(RethRpcModule::Debug, debug_ext.into_rpc())?; @@ -322,10 +324,16 @@ where // install the miner extension in the authenticated if configured if modules.module_config().contains_any(&RethRpcModule::Miner) { - debug!(target: "reth::cli", "Installing miner DA rpc enddpoint"); + debug!(target: "reth::cli", "Installing miner DA rpc endpoint"); auth_modules.merge_auth_methods(miner_ext.into_rpc())?; } + // install the debug namespace in the authenticated if configured + if modules.module_config().contains_any(&RethRpcModule::Debug) { + debug!(target: "reth::cli", "Installing debug rpc endpoint"); + auth_modules.merge_auth_methods(registry.debug_api().into_rpc())?; + } + if enable_tx_conditional { // extend the eth namespace if configured in the regular http server modules.merge_if_module_configured(