private void warnIfImportedBlocksAreNotOnCanonicalChain(final List<Block> importedBlocks) {
    final List<BlockHeader> nonCanonicalHeaders =
        importedBlocks.stream()
            .map(Block::getHeader)
            .filter(
                header ->
                    controller
                        .getProtocolContext()
                        .getBlockchain()
                        .getBlockHeader(header.getNumber())
                        .map(c -> !c.equals(header))
                        .orElse(true))
            .collect(Collectors.toList());
    if (nonCanonicalHeaders.size() > 0) {
      final String blocksString =
          nonCanonicalHeaders.stream()
              .map(h -> "#" + h.getNumber() + " (" + h.getHash() + ")")
              .collect(Collectors.joining(", "));
      LOG.warn(
          "{} / {} imported blocks are not on the canonical chain: {}",
          nonCanonicalHeaders.size(),
          importedBlocks.size(),
          blocksString);
    }
  }
Import chain.

@param chainJson the chain json
@throws IOException the io exception
app/src/main/java/org/hyperledger/besu/chainimport/JsonBlockImporter.java