def contract_last_update_search(p, contract_hash, end=(- 1)):
    head_level = p.shell.head.header()['level']
    contract = p.contract(contract_hash)
    (origin_level, data) = contract_origin_search(p, contract_hash)
    if ((end > 0) and (end < origin_level)):
        return ((- 1), [(- 1), None])
    end = end
    if ((end == (- 1)) or (end > head_level)):
        end = head_level
    for lvl in range(end, origin_level, (- 1)):
        new_data = contract.storage(lvl)
        prev_data = contract.storage((lvl - 1))
        if (new_data != prev_data):
            print('Ntf end:', contract_hash, end, lvl, new_data, '\n')
            return (end, [lvl, new_data])
    return (end, [(- 1), None])
def contract_last_update_search(p, contract_hash, end=(- 1)):
    head_level = p.shell.head.header()['level']
    contract = p.contract(contract_hash)
    (origin_level, data) = contract_origin_search(p, contract_hash)
    if ((end > 0) and (end < origin_level)):
        return ((- 1), [(- 1), None])
    end = end
    if ((end == (- 1)) or (end > head_level)):
        end = head_level
    for lvl in range(end, origin_level, (- 1)):
        new_data = contract.storage(lvl)
        prev_data = contract.storage((lvl - 1))
        if (new_data != prev_data):
            print('Ntf end:', contract_hash, end, lvl, new_data, '\n')
            return (end, [lvl, new_data])
    return (end, [(- 1), None])