@Override
  public Optional<TransactionSimulationResult> simulate(
      final Transaction transaction,
      final Optional<StateOverrideMap> maybeStateOverrides,
      final Hash blockHash,
      final OperationTracer operationTracer,
      final boolean isAllowExceedingBalance) {

    final CallParameter callParameter = CallParameter.fromTransaction(transaction);

    final var maybeBlockHeader =
        blockchain.getBlockHeader(blockHash).or(() -> blockchain.getBlockHeaderSafe(blockHash));

    if (maybeBlockHeader.isEmpty()) {
      return Optional.of(
          new TransactionSimulationResult(
              transaction,
              TransactionProcessingResult.invalid(
                  ValidationResult.invalid(TransactionInvalidReason.BLOCK_NOT_FOUND))));
    }

    return transactionSimulator
        .process(
            callParameter,
            isAllowExceedingBalance
                ? transactionSimulatorAllowExceedingBalance()
                : transactionSimulator(),
            operationTracer,
            maybeBlockHeader.get())
        .map(res -> new TransactionSimulationResult(transaction, res.result()));
  }
Configure the service

@param blockchain the blockchain
@param transactionSimulator transaction simulator
app/src/main/java/org/hyperledger/besu/services/TransactionSimulationServiceImpl.java