class DebugTraceBlock implements JsonRpcMethod {

  @Override
  public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
    final String input = requestContext.getRequiredParameter(0, String.class);
    final Block block;
    try {
      block = Block.readFrom(RLP.input(Bytes.fromHexString(input)), this.blockHeaderFunctions);
    } catch (final RLPException e) {
      LOG.debug("Failed to parse block RLP", e);
      return new JsonRpcErrorResponse(
          requestContext.getRequest().getId(), JsonRpcError.INVALID_PARAMS);
    }
    final TraceOptions traceOptions =
        requestContext
            .getOptionalParameter(1, TransactionTraceParams.class)
            .map(TransactionTraceParams::traceOptions)
            .orElse(TraceOptions.DEFAULT);

    if (this.blockchain.blockByHash(block.getHeader().getParentHash()).isPresent()) {
      final Collection<DebugTraceTransactionResult> results =
          blockTracerSupplier
              .get()
              .trace(block, new DebugOperationTracer(traceOptions))
              .map(BlockTrace::getTransactionTraces)
              .map(DebugTraceTransactionResult::of)
              .orElse(null);
      return new JsonRpcSuccessResponse(requestContext.getRequest().getId(), results);
    } else {
      return new JsonRpcErrorResponse(
          requestContext.getRequest().getId(), JsonRpcError.PARENT_BLOCK_NOT_FOUND);
    }
  }

  public  DebugTraceBlock(
      final Supplier<BlockTracer> blockTracerSupplier,
      final BlockHeaderFunctions blockHeaderFunctions,
      final BlockchainQueries blockchain);

}