public Set<Address> getAddressesTouchedByTransaction(
      final Transaction transaction,
      final Optional<PathBasedWorldStateUpdateAccumulator<?>> accumulator) {
    HashSet<Address> addresses = new HashSet<>();
    addresses.add(transaction.getSender());
    if (transaction.getTo().isPresent()) {
      addresses.add(transaction.getTo().get());
    }
    accumulator.ifPresent(
        pathBasedWorldStateUpdateAccumulator -> {
          pathBasedWorldStateUpdateAccumulator
              .getAccountsToUpdate()
              .forEach(
                  (address, pathBasedValue) -> {
                    addresses.add(address);
                  });
          addresses.addAll(pathBasedWorldStateUpdateAccumulator.getDeletedAccountAddresses());
        });

    return addresses;
  }
Retrieves the set of addresses that were touched by a transaction. This includes the sender and
recipient of the transaction, as well as any addresses that were read from or written to by the
transaction's execution.

@param transaction The transaction to analyze.
@param accumulator An optional accumulator containing state changes made by the transaction.
@return A set of addresses touched by the transaction.
ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/parallelization/TransactionCollisionDetector.java