diff --git a/packages/client/bin/cli.ts b/packages/client/bin/cli.ts index ec6fbdcc9d..fe43ee0292 100755 --- a/packages/client/bin/cli.ts +++ b/packages/client/bin/cli.ts @@ -204,8 +204,10 @@ const args: ClientOpts = yargs(hideBin(process.argv)) default: 5, }) .option('rpcDebug', { - describe: 'Additionally log complete RPC calls on log level debug (i.e. --loglevel=debug)', - boolean: true, + describe: + 'Additionally log complete RPC calls on log level debug (i.e. --loglevel=debug). Can indicate a specific module or a boolean.', + choices: ['true', 'false', 'eth', 'engine'], + default: 'false', }) .option('rpcCors', { describe: 'Configure the Access-Control-Allow-Origin CORS header for RPC server', diff --git a/packages/client/bin/startRpc.ts b/packages/client/bin/startRpc.ts index be03d94749..9a7e2fb85a 100644 --- a/packages/client/bin/startRpc.ts +++ b/packages/client/bin/startRpc.ts @@ -26,7 +26,7 @@ export type RPCArgs = { rpcEnginePort: number wsEngineAddr: string wsEnginePort: number - rpcDebug: boolean + rpcDebug: string helpRpc: boolean jwtSecret?: string rpcEngineAuth: boolean diff --git a/packages/client/src/types.ts b/packages/client/src/types.ts index ce96ecb37f..3de5998dba 100644 --- a/packages/client/src/types.ts +++ b/packages/client/src/types.ts @@ -129,7 +129,7 @@ export interface ClientOpts { logLevelFile?: string logRotate?: boolean logMaxFiles?: number - rpcDebug?: boolean + rpcDebug?: string rpcCors?: string maxPerRequest?: number maxFetcherJobs?: number diff --git a/packages/client/src/util/rpc.ts b/packages/client/src/util/rpc.ts index bdd00f8e6f..8ce6194156 100644 --- a/packages/client/src/util/rpc.ts +++ b/packages/client/src/util/rpc.ts @@ -17,7 +17,7 @@ const algorithm: TAlgorithm = 'HS256' type CreateRPCServerOpts = { methodConfig: MethodConfig - rpcDebug: boolean + rpcDebug: string logger?: Logger } type CreateRPCServerReturn = { @@ -67,7 +67,11 @@ export function createRPCServer( const onRequest = (request: any) => { let msg = '' - if (rpcDebug) { + if ( + rpcDebug === 'true' || + (rpcDebug === 'engine' && request.method.includes('engine_') === true) || + (rpcDebug === 'eth' && request.method.includes('eth_') === true) + ) { msg += `${request.method} called with params:\n${inspectParams(request.params)}` } else { msg += `${request.method} called with params: ${inspectParams(request.params, 125)}` @@ -77,7 +81,11 @@ export function createRPCServer( const handleResponse = (request: any, response: any, batchAddOn = '') => { let msg = '' - if (rpcDebug) { + if ( + rpcDebug === 'true' || + (rpcDebug === 'engine' && request.method.includes('engine_') === true) || + (rpcDebug === 'eth' && request.method.includes('eth_') === true) + ) { msg = `${request.method}${batchAddOn} responded with:\n${inspectParams(response)}` } else { msg = `${request.method}${batchAddOn} responded with: ` @@ -107,11 +115,11 @@ export function createRPCServer( } let methods - const ethMethods = manager.getMethods(false, rpcDebug) + const ethMethods = manager.getMethods(false, rpcDebug !== 'false') switch (methodConfig) { case MethodConfig.WithEngine: - methods = { ...ethMethods, ...manager.getMethods(true, rpcDebug) } + methods = { ...ethMethods, ...manager.getMethods(true, rpcDebug !== 'false') } break case MethodConfig.WithoutEngine: methods = { ...ethMethods }