<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def check_recovery(working_dir):
 """ Do we need to recover on start-up? """

    recovery_start_block, recovery_end_block = get_recovery_range(working_dir)
    if recovery_start_block is not None and recovery_end_block is not None:
        local_current_block = virtualchain_hooks.get_last_block(working_dir)
        if local_current_block <= recovery_end_block:
            return True

        # otherwise, we're outside the recovery range and we can clear it
        log.debug('Chain state is at block {}, and is outside the recovery window {}-{}'.format(local_current_block, recovery_start_block, recovery_end_block))
        clear_recovery_range(working_dir)
        return False

    else:
        # not recovering
        return False