Search through the blockstore and return a tuple containing:
        - the first block with a missing state root
        - the state root of that blocks predecessor

def search_for_present_state_root(blockstore, state_view_factory):
    """
    Search through the blockstore and return a tuple containing:
        - the first block with a missing state root
        - the state root of that blocks predecessor
    """
    # If there is no chain to process, then we are done.
    block = blockstore.chain_head
    if block is None:
        return None, None

    # Check the head first
    if state_db_has_root(state_view_factory, block.state_root_hash):
        return None, None

    prev_state_root = INIT_ROOT_KEY
    for block in blockstore.get_block_iter(reverse=False):
        if not state_db_has_root(state_view_factory, block.state_root_hash):
            return block, prev_state_root
        prev_state_root = block.state_root_hash

    # This should never happen, since we already checked that the chain head
    # didn't have a state root
    raise ExecutionError(
        "Chain head state both missing but all blocks had state root present")