public static BlockHeaderBuilder createPending(
      final ProtocolSpec protocolSpec,
      final BlockHeader parentHeader,
      final MiningConfiguration miningConfiguration,
      final long timestamp,
      final Optional<Bytes32> maybePrevRandao,
      final Optional<Bytes32> maybeParentBeaconBlockRoot) {

    final long newBlockNumber = parentHeader.getNumber() + 1;
    final long gasLimit =
        protocolSpec
            .getGasLimitCalculator()
            .nextGasLimit(
                parentHeader.getGasLimit(),
                miningConfiguration.getTargetGasLimit().orElse(parentHeader.getGasLimit()),
                newBlockNumber);

    final DifficultyCalculator difficultyCalculator = protocolSpec.getDifficultyCalculator();
    final var difficulty =
        Difficulty.of(difficultyCalculator.nextDifficulty(timestamp, parentHeader));

    final Wei baseFee;
    if (protocolSpec.getFeeMarket().implementsBaseFee()) {
      final var baseFeeMarket = (BaseFeeMarket) protocolSpec.getFeeMarket();
      baseFee =
          baseFeeMarket.computeBaseFee(
              newBlockNumber,
              parentHeader.getBaseFee().orElse(Wei.ZERO),
              parentHeader.getGasUsed(),
              baseFeeMarket.targetGasUsed(parentHeader));
    } else {
      baseFee = null;
    }

    final Bytes32 prevRandao = maybePrevRandao.orElse(null);
    final Bytes32 parentBeaconBlockRoot = maybeParentBeaconBlockRoot.orElse(null);

    return BlockHeaderBuilder.create()
        .parentHash(parentHeader.getHash())
        .coinbase(miningConfiguration.getCoinbase().orElseThrow())
        .difficulty(difficulty)
        .number(newBlockNumber)
        .gasLimit(gasLimit)
        .timestamp(timestamp)
        .baseFee(baseFee)
        .prevRandao(prevRandao)
        .parentBeaconBlockRoot(parentBeaconBlockRoot);
  }
A utility class for building block headers.
ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/BlockHeaderBuilder.java