@Override
  public Hash apply(final MessageFrame frame, final Long blockNumber) {
    final Hash cachedHash = hashByNumber.get(blockNumber);
    if (cachedHash != null) {
      return cachedHash;
    }
    while (searchStartHeader != null && searchStartHeader.getNumber() - 1 > blockNumber) {
      searchStartHeader = blockchain.getBlockHeader(searchStartHeader.getParentHash()).orElse(null);
      if (searchStartHeader != null) {
        hashByNumber.put(searchStartHeader.getNumber() - 1, searchStartHeader.getParentHash());
      }
    }
    return hashByNumber.getOrDefault(blockNumber, ZERO);
  }
Calculates and caches block hashes by number following the chain for a specific branch. This is
used by {@link BlockHashOperation} and ensures that the correct block hash is returned even when
the block being imported is on a fork.

<p>A new BlockHashCache must be created for each block being processed but should be reused for
all transactions within that block.
ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/BlockchainBasedBlockHashLookup.java