private BlockTraceResult traceBlock(
      final Optional<Block> maybeBlock, final BlockAwareOperationTracer tracer) {
    checkArgument(tracer != null);
    if (maybeBlock.isEmpty()) {
      return BlockTraceResult.empty();
    }

    final Optional<List<TransactionProcessingResult>> results = trace(maybeBlock.get(), tracer);

    if (results.isEmpty()) {
      return BlockTraceResult.empty();
    }

    final BlockTraceResult.Builder builder = BlockTraceResult.builder();

    final List<TransactionProcessingResult> transactionProcessingResults = results.get();
    final List<Transaction> transactions = maybeBlock.get().getBody().getTransactions();
    for (int i = 0; i < transactionProcessingResults.size(); i++) {
      final TransactionProcessingResult transactionProcessingResult =
          transactionProcessingResults.get(i);
      final TransactionTraceResult transactionTraceResult =
          transactionProcessingResult.isInvalid()
              ? TransactionTraceResult.error(
                  transactions.get(i).getHash(),
                  transactionProcessingResult.getValidationResult().getErrorMessage())
              : TransactionTraceResult.success(transactions.get(i).getHash());

      builder.addTransactionTraceResult(transactionTraceResult);
    }

    return builder.build();
  }
Traces block

@param hash the block hash to be traced
@param tracer an instance of OperationTracer
app/src/main/java/org/hyperledger/besu/services/TraceServiceImpl.java