@@ -312,19 +312,38 @@ export class TracerConfigWrapper extends DefaultValidation<ITracerConfigWrapper>
312312
313313 const { tracer, tracerConfig } = this . object ;
314314
315+ // currently we don't support prestate tracer for traceTransaction
316+ if ( tracer === TracerType . PrestateTracer ) {
317+ throw predefined . INTERNAL_ERROR ( 'Prestate tracer is not yet supported on debug_traceTransaction' ) ;
318+ }
319+
320+ if ( ! tracerConfig ) {
321+ return valid ;
322+ }
323+
324+ const keys = Object . keys ( tracerConfig ?? { } ) ;
325+
326+ const callTracerKeys = [ 'onlyTopCall' ] ;
327+ const opcodeLoggerKeys = [ 'enableMemory' , 'disableStack' , 'disableStorage' ] ;
328+
329+ const hasCallTracerKeys = keys . some ( ( k ) => callTracerKeys . includes ( k ) ) ;
315330 // we want to accept ICallTracerConfig only if the tracer is callTracer
316- // this config is not valid for opcodeLogger
317- if (
318- tracerConfig &&
319- ( tracerConfig as ICallTracerConfig ) . onlyTopCall !== undefined &&
320- tracer !== TracerType . CallTracer
321- ) {
331+ // this config is not valid for opcodeLogger and vice versa
332+ // accept only IOpcodeLoggerConfig with opcodeLogger tracer
333+ if ( hasCallTracerKeys && tracer !== TracerType . CallTracer ) {
322334 throw predefined . INVALID_PARAMETER (
323335 1 ,
324- `'tracerConfig' for ${ this . name ( ) } onlyTopCall is only valid when tracer=${ TracerType . CallTracer } ` ,
336+ `callTracer 'tracerConfig' for ${ this . name ( ) } is only valid when tracer=${ TracerType . CallTracer } ` ,
325337 ) ;
326338 }
327339
340+ const hasOpcodeLoggerKeys = keys . some ( ( k ) => opcodeLoggerKeys . includes ( k ) ) ;
341+ if ( hasOpcodeLoggerKeys && tracer !== TracerType . OpcodeLogger ) {
342+ throw predefined . INVALID_PARAMETER (
343+ 1 ,
344+ `opcodeLogger 'tracerConfig' for ${ this . name ( ) } is only valid when tracer=${ TracerType . OpcodeLogger } ` ,
345+ ) ;
346+ }
328347 return valid ;
329348 }
330349}
0 commit comments