private static FlatTrace.Context handleHalt(
      final List<FlatTrace.Builder> flatTraces,
      final Deque<FlatTrace.Context> tracesContexts,
      final FlatTrace.Context currentContext,
      final TraceFrame traceFrame) {
    final FlatTrace.Builder traceFrameBuilder;
    if (currentContext == null) {
      traceFrameBuilder = flatTraces.get(flatTraces.size() - 1);
    } else {
      traceFrameBuilder = currentContext.getBuilder();
    }
    traceFrameBuilder.error(
        traceFrame
            .getExceptionalHaltReason()
            .map(
                exceptionalHaltReason -> {
                  if (exceptionalHaltReason
                      .name()
                      .equals(ExceptionalHaltReason.INVALID_OPERATION.name())) {
                    return ExceptionalHaltReason.INVALID_OPERATION.getDescription();
                  } else {
                    return exceptionalHaltReason.getDescription();
                  }
                }));
    if (currentContext != null) {
      final Action.Builder actionBuilder = traceFrameBuilder.getActionBuilder();
      actionBuilder.value(Quantity.create(traceFrame.getValue()));
      tracesContexts.removeLast();
      final FlatTrace.Context nextContext = tracesContexts.peekLast();
      if (nextContext != null) {
        nextContext.getBuilder().incSubTraces();
      }
      return nextContext;
    }
    return currentContext;
  }
Generates a stream of {@link Trace} from the passed {@link TransactionTrace} and {@link Block}
data with additional Transaction Information added to FlatTrace

@param protocolSchedule the current {@link ProtocolSchedule} to use
@param transactionTrace the {@link TransactionTrace} to use
@param block the {@link Block} to use
@return a stream of generated traces {@link Trace}
ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/tracing/flat/FlatTraceGenerator.java