Example #1
0
def generate_mock_latest_block_roots(genesis_block, current_slot, epoch_length,
                                     latest_block_roots_length):
    assert current_slot < latest_block_roots_length

    chain_length = (current_slot // epoch_length + 1) * epoch_length
    blocks = get_pseudo_chain(chain_length, genesis_block)
    latest_block_roots = [block.hash for block in blocks[:current_slot]] + [
        ZERO_HASH32 for _ in range(latest_block_roots_length - current_slot)
    ]
    return blocks, latest_block_roots
Example #2
0
def generate_mock_latest_historical_roots(genesis_block, current_slot,
                                          slots_per_epoch,
                                          slots_per_historical_root):
    assert current_slot < slots_per_historical_root

    chain_length = (current_slot // slots_per_epoch + 1) * slots_per_epoch
    blocks = get_pseudo_chain(chain_length, genesis_block)
    latest_block_roots = [block.hash for block in blocks[:current_slot]] + [
        ZERO_HASH32 for _ in range(slots_per_historical_root - current_slot)
    ]
    return blocks, latest_block_roots