private static String calculateCallingAddress(final FlatTrace.Context lastContext) {
    final FlatTrace.Builder lastContextBuilder = lastContext.getBuilder();
    final Action.Builder lastActionBuilder = lastContextBuilder.getActionBuilder();
    if (lastActionBuilder.getCallType() == null) {
      if ("create".equals(lastContextBuilder.getType())) {
        return lastContextBuilder.getResultBuilder().getAddress();
      } else {
        return ZERO_ADDRESS_STRING;
      }
    }
    switch (lastActionBuilder.getCallType()) {
      case "call":
      case "staticcall":
        return lastActionBuilder.getTo();
      case "delegatecall":
      case "callcode":
        return lastActionBuilder.getFrom();
      case "create":
      case "create2":
        return lastContextBuilder.getResultBuilder().getAddress();
      default:
        return ZERO_ADDRESS_STRING;
    }
  }
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