@VisibleForTesting
  protected BlockHeader overrideBlockHeader(
      final BlockHeader header,
      final ProtocolSpec newProtocolSpec,
      final BlockOverrides blockOverrides,
      final boolean shouldValidate) {
    long timestamp = blockOverrides.getTimestamp().orElseThrow();
    long blockNumber = blockOverrides.getBlockNumber().orElseThrow();

    BlockHeaderBuilder builder =
        BlockHeaderBuilder.createDefault()
            .parentHash(header.getHash())
            .timestamp(timestamp)
            .number(blockNumber)
            .coinbase(
                blockOverrides
                    .getFeeRecipient()
                    .orElseGet(() -> miningConfiguration.getCoinbase().orElseThrow()))
            .difficulty(
                blockOverrides.getDifficulty().map(Difficulty::of).orElseGet(header::getDifficulty))
            .gasLimit(
                blockOverrides
                    .getGasLimit()
                    .orElseGet(() -> getNextGasLimit(newProtocolSpec, header, blockNumber)))
            .baseFee(
                blockOverrides
                    .getBaseFeePerGas()
                    .orElseGet(
                        () ->
                            shouldValidate
                                ? getNextBaseFee(newProtocolSpec, header, blockNumber)
                                : Wei.ZERO))
            .extraData(blockOverrides.getExtraData().orElse(Bytes.EMPTY))
            .parentBeaconBlockRoot(Bytes32.ZERO)
            .prevRandao(blockOverrides.getMixHashOrPrevRandao().orElse(Bytes32.ZERO));

    return builder
        .blockHeaderFunctions(new BlockStateCallBlockHeaderFunctions(blockOverrides))
        .buildBlockHeader();
  }
Applies block header overrides to the block header.

@param header The original block header.
@param newProtocolSpec The ProtocolSpec for the block.
@param blockOverrides The BlockOverrides to apply.
@return The modified block header.
ethereum/core/src/main/java/org/hyperledger/besu/ethereum/transaction/BlockSimulator.java