private void cancelEvaluatingTxWithGraceTime(final FutureTask<Void> txSelectionTask) {
    final long elapsedTime =
        currTxEvaluationContext.getEvaluationTimer().elapsed(TimeUnit.MILLISECONDS);
    // adding 100ms so we are sure it take strictly more than the block selection max time
    final long txRemainingTime = (blockTxsSelectionMaxTime - elapsedTime) + 100;

    LOG.atDebug()
        .setMessage(
            "Transaction {} is processing for {}ms, giving it {}ms grace time, before considering it taking too much time to execute")
        .addArgument(currTxEvaluationContext.getPendingTransaction()::toTraceLog)
        .addArgument(elapsedTime)
        .addArgument(txRemainingTime)
        .log();

    ethScheduler.scheduleFutureTask(
        () -> {
          if (!txSelectionTask.isDone()) {
            LOG.atDebug()
                .setMessage(
                    "Transaction {} is still processing after the grace time, total processing time {}ms,"
                        + " greater than max block selection time of {}ms, forcing an interrupt")
                .addArgument(currTxEvaluationContext.getPendingTransaction()::toTraceLog)
                .addArgument(
                    () ->
                        currTxEvaluationContext.getEvaluationTimer().elapsed(TimeUnit.MILLISECONDS))
                .addArgument(blockTxsSelectionMaxTime)
                .log();

            txSelectionTask.cancel(true);
          }
        },
        Duration.ofMillis(txRemainingTime));
  }
Builds a list of transactions for a block by iterating over all transactions in the
PendingTransactions pool. This operation can be long-running and, if executed in a separate
thread, can be cancelled via the isCancelled supplier, which would result in a
CancellationException.

@return The {@code TransactionSelectionResults} containing the results of transaction
    evaluation.
ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/BlockTransactionSelector.java