Skip to content
This repository has been archived by the owner on Jul 1, 2021. It is now read-only.

Add get_permuted_index and new swap-or-not shuffle #363

Merged
merged 4 commits into from
Mar 8, 2019

Conversation

hwwhww
Copy link
Contributor

@hwwhww hwwhww commented Mar 4, 2019

What was wrong?

Fix #272

How was it fixed?

  1. Add constants MAX_EXIT_DEQUEUES_PER_EPOCH and SHUFFLE_ROUND_COUNT
  2. Add get_permuted_index and new swap or not shuffle
  3. Use the results of two different approaches to test

Cute Animal Picture

tiger-3096211_640

@hwwhww hwwhww added the eth2.0 label Mar 4, 2019
@hwwhww hwwhww changed the title Add get_permuted_index and new swap or not shuffle Add get_permuted_index and new swap-or-not shuffle Mar 4, 2019
@hwwhww hwwhww requested a review from NIC619 March 4, 2019 12:51
Copy link
Contributor

@NIC619 NIC619 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

eth2/beacon/_utils/random.py Outdated Show resolved Hide resolved
def get_permuted_index(index: int,
list_size: int,
seed: Hash32,
shuffle_round_count: int=90) -> int:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious about the reason for a hardcoded default shuffle_round_count value and does it makes sense to use a constant instead?

h = hash_eth2(seed + round.to_bytes(1, 'little') + (hash_pos // 256).to_bytes(4, 'little'))
byte = h[(hash_pos % 256) // 8]
bit = (byte >> (hash_pos % 8)) % 2
index = flip if bit else index
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe not overwrite the input variables.

@@ -327,6 +333,7 @@ def get_crosslink_committees_at_slot(
slots_per_epoch=slots_per_epoch,
target_committee_size=target_committee_size,
shard_count=shard_count,
shuffle_round_count=shuffle_round_count,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can group these into CommitteeConfig.

hwwhww and others added 4 commits March 7, 2019 20:06
1. Add constants `MAX_EXIT_DEQUEUES_PER_EPOCH` and `SHUFFLE_ROUND_COUNT`
2. Add `get_permuted_index` and new swap or not `shuffle`
3. Use the results of two different approaches to test
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement swap-or-not shuffle
2 participants