public Wei gasPriorityFee() {
    final Block chainHeadBlock = blockchain.getChainHeadBlock();
    final long blockHeight = chainHeadBlock.getHeader().getNumber();

    final Wei[] gasCollection =
        Stream.concat(
                LongStream.range(
                        Math.max(0, blockHeight - apiConfig.getGasPriceBlocks() + 1), blockHeight)
                    .mapToObj(
                        l ->
                            blockchain
                                .getBlockByNumber(l)
                                .orElseThrow(
                                    () ->
                                        new IllegalStateException(
                                            "Could not retrieve block #" + l))),
                Stream.of(chainHeadBlock))
            .map(Block::getBody)
            .map(BlockBody::getTransactions)
            .flatMap(Collection::stream)
            .filter(t -> t.getMaxPriorityFeePerGas().isPresent())
            .map(t -> t.getMaxPriorityFeePerGas().get())
            .sorted()
            .toArray(Wei[]::new);

    return gasCollection.length == 0
        ? miningConfiguration.getMinPriorityFeePerGas()
        : UInt256s.max(
            miningConfiguration.getMinPriorityFeePerGas(),
            gasCollection[
                Math.min(
                    gasCollection.length - 1,
                    (int) ((gasCollection.length) * apiConfig.getGasPriceFraction()))]);
  }
Return the min gas required for a tx to be mineable. On networks with gas price fee market it
is just the minGasPrice, while on networks with base fee market it is the max between the
minGasPrice and the baseFee for the next block.

@return the min gas required for a tx to be mineable.
ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/query/BlockchainQueries.java