From d7e315de38a82fc5d5b8a3aaffbac679ecda3a9f Mon Sep 17 00:00:00 2001 From: Victor Yanev <161485803+victor-yanev@users.noreply.github.com> Date: Thu, 27 Jun 2024 18:07:17 +0300 Subject: [PATCH] fix: debug_traceTransaction not working when we don't pass tracerConfig (#2628) Signed-off-by: Victor Yanev --- packages/server/src/server.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/server/src/server.ts b/packages/server/src/server.ts index 85b7dfa112..8409c38e44 100644 --- a/packages/server/src/server.ts +++ b/packages/server/src/server.ts @@ -18,7 +18,7 @@ * */ -import { Relay, RelayImpl, JsonRpcError, predefined, MirrorNodeClientError } from '@hashgraph/json-rpc-relay'; +import { JsonRpcError, MirrorNodeClientError, predefined, Relay, RelayImpl } from '@hashgraph/json-rpc-relay'; import { collectDefaultMetrics, Histogram, Registry } from 'prom-client'; import KoaJsonRpc from './koaJsonRpc'; import { TracerType, Validator } from './validator'; @@ -663,7 +663,14 @@ app.useRpc('eth_maxPriorityFeePerGas', async () => { app.useRpc('debug_traceTransaction', async (params: any) => { const transactionIdOrHash = params[0]; const { tracer, ...otherParams } = params[1]; - const tracerConfig = tracer === TracerType.CallTracer ? otherParams.tracerConfig : otherParams; + + let tracerConfig: object; + if (tracer === TracerType.CallTracer) { + tracerConfig = otherParams?.tracerConfig ?? { onlyTopCall: false }; + } else { + tracerConfig = otherParams ?? { disableMemory: false, disableStack: false, disableStorage: false }; + } + return logAndHandleResponse('debug_traceTransaction', [transactionIdOrHash, tracer, tracerConfig], (requestId) => relay.eth().debugService().debug_traceTransaction(transactionIdOrHash, tracer, tracerConfig, requestId), );