def METHOD_NAME(parent_block: 'Block', timestamp: int) -> float:
    """ Calculate the next block weight, aka DAA/difficulty adjustment algorithm.
    The algorithm used is described in [RFC 22](https://gitlab.com/HathorNetwork/rfcs/merge_requests/22).
    The weight must not be less than `MIN_BLOCK_WEIGHT`.
    """
    if TEST_MODE & TestMode.TEST_BLOCK_WEIGHT:
        return 1.0
    from hathor.transaction import sum_weights
    root = parent_block
    N = min(2 * settings.BLOCK_DIFFICULTY_N_BLOCKS, parent_block.get_height() - 1)
    K = N // 2
    T = AVG_TIME_BETWEEN_BLOCKS
    S = 5
    if N < 10:
        return MIN_BLOCK_WEIGHT
    blocks: list['Block'] = []
    while len(blocks) < N + 1:
        blocks.append(root)
        root = root.get_block_parent()
        assert root is not None
    # TODO: revise if this assertion can be safely removed
    assert blocks == sorted(blocks, key=lambda tx: -tx.timestamp)
    blocks = list(reversed(blocks))
    assert len(blocks) == N + 1
    solvetimes, weights = zip(*(
        (block.timestamp - prev_block.timestamp, block.weight)
        for prev_block, block in iwindows(blocks, 2)
    ))
    assert len(solvetimes) == len(weights) == N, f'got {len(solvetimes)}, {len(weights)} expected {N}'
    sum_solvetimes = 0.0
    logsum_weights = 0.0
    prefix_sum_solvetimes = [0]
    for st in solvetimes:
        prefix_sum_solvetimes.append(prefix_sum_solvetimes[-1] + st)
    # Loop through N most recent blocks. N is most recently solved block.
    for i in range(K, N):
        solvetime = solvetimes[i]
        weight = weights[i]
        x = (prefix_sum_solvetimes[i + 1] - prefix_sum_solvetimes[i - K]) / K
        ki = K * (x - T)**2 / (2 * T * T)
        ki = max(1, ki / S)
        sum_solvetimes += ki * solvetime
        logsum_weights = sum_weights(logsum_weights, log(ki, 2) + weight)
    weight = logsum_weights - log(sum_solvetimes, 2) + log(T, 2)
    # Apply weight decay
    weight -= get_weight_decay_amount(timestamp - parent_block.timestamp)
    # Apply minimum weight
    if weight < MIN_BLOCK_WEIGHT:
        weight = MIN_BLOCK_WEIGHT
    return weight