public long calculateSimulationGasCap(
      final ProcessableBlockHeader blockHeader,
      final OptionalLong maybeUserProvidedGasLimit,
      final long blockGasLimit) {
    final long simulationGasCap;

    if (maybeUserProvidedGasLimit.isPresent()) {
      long userProvidedGasLimit = maybeUserProvidedGasLimit.getAsLong();
      if (rpcGasCap > 0 && userProvidedGasLimit > rpcGasCap) {
        LOG.trace(
            "User provided gas limit {} is bigger than the value of rpc-gas-cap {}, setting simulation gas cap to the latter",
            userProvidedGasLimit,
            rpcGasCap);
        simulationGasCap = rpcGasCap;
      } else {
        LOG.trace("Using provided gas limit {} set as simulation gas cap", userProvidedGasLimit);
        simulationGasCap = userProvidedGasLimit;
      }
    } else {
      final long txGasLimitCap =
          protocolSchedule
              .getByBlockHeader(blockHeader)
              .getGasLimitCalculator()
              .transactionGasLimitCap();
      if (rpcGasCap > 0) {
        simulationGasCap = Math.min(rpcGasCap, Math.min(txGasLimitCap, blockGasLimit));
        LOG.trace(
            "No user provided gas limit, setting simulation gas cap to the value of min(rpc-gas-cap={},txGasLimitCap={},blockGasLimit={})={}",
            rpcGasCap,
            txGasLimitCap,
            blockGasLimit,
            simulationGasCap);
      } else {
        simulationGasCap = Math.min(txGasLimitCap, blockGasLimit);
        LOG.trace(
            "No user provided gas limit and rpc-gas-cap options is not set, setting simulation gas cap to min(txGasLimitCap={},blockGasLimit={})={}",
            txGasLimitCap,
            blockGasLimit,
            simulationGasCap);
      }
    }
    return simulationGasCap;
  }
Processes a transaction simulation with the provided parameters and executes pre-worldstate
close actions.

@param callParams The call parameters for the transaction.
@param maybeStateOverrides The map of state overrides to apply to the state for this
    transaction.
@param transactionValidationParams The validation parameters for the transaction.
@param operationTracer The tracer for capturing operations during processing.
@param preWorldStateCloseGuard The pre-worldstate close guard for executing pre-close actions.
@param header The block header.
@return An Optional containing the result of the processing.
ethereum/core/src/main/java/org/hyperledger/besu/ethereum/transaction/TransactionSimulator.java