From b92cd9be03b16db86caf5c9498df8a5c3bf5d848 Mon Sep 17 00:00:00 2001 From: Paul Hauner Date: Sat, 16 Feb 2019 17:55:27 +1100 Subject: [PATCH 1/3] Add fix to `get_shuffling` Ensures it does not try to shuffle out of range of the `active_validator_indices` list. --- specs/core/0_beacon-chain.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/specs/core/0_beacon-chain.md b/specs/core/0_beacon-chain.md index ce13c6105f..80bb126352 100644 --- a/specs/core/0_beacon-chain.md +++ b/specs/core/0_beacon-chain.md @@ -807,7 +807,7 @@ def get_shuffling(seed: Bytes32, # Shuffle shuffled_active_validator_indices = [ active_validator_indices[get_permuted_index(i, len(active_validator_indices), seed)] - for i in active_validator_indices + for i in range(len(active_validator_indices)) ] # Split the shuffled list into committees_per_epoch pieces From 1d95c1482c26b454ac73fc01e985c14702ba69b4 Mon Sep 17 00:00:00 2001 From: Justin Date: Sat, 16 Feb 2019 21:11:48 +0000 Subject: [PATCH 2/3] Update 0_beacon-chain.md --- specs/core/0_beacon-chain.md | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/specs/core/0_beacon-chain.md b/specs/core/0_beacon-chain.md index 80bb126352..832b8e523d 100644 --- a/specs/core/0_beacon-chain.md +++ b/specs/core/0_beacon-chain.md @@ -795,23 +795,16 @@ def get_shuffling(seed: Bytes32, validators: List[Validator], epoch: Epoch) -> List[List[ValidatorIndex]] """ - Shuffle ``validators`` into crosslink committees seeded by ``seed`` and ``epoch``. - Return a list of ``committees_per_epoch`` committees where each - committee is itself a list of validator indices. + Shuffle (seeded by ``seed`` and ``epoch``) active validators and split into crosslink committees. + Return a list of committees (each a list of validator indices). """ - + # Shuffle active validator indices active_validator_indices = get_active_validator_indices(validators, epoch) + length = len(active_validator_indices) + shuffled_indices = [active_validator_indices[get_permuted_index(i, length, seed)] for i in range(length)] - committees_per_epoch = get_epoch_committee_count(len(active_validator_indices)) - - # Shuffle - shuffled_active_validator_indices = [ - active_validator_indices[get_permuted_index(i, len(active_validator_indices), seed)] - for i in range(len(active_validator_indices)) - ] - - # Split the shuffled list into committees_per_epoch pieces - return split(shuffled_active_validator_indices, committees_per_epoch) + # Split the shuffled active validator indices + return split(shuffled_indices, get_epoch_committee_count(length)) ``` **Invariant**: if `get_shuffling(seed, validators, epoch)` returns some value `x` for some `epoch <= get_current_epoch(state) + ACTIVATION_EXIT_DELAY`, it should return the same value `x` for the same `seed` and `epoch` and possible future modifications of `validators` forever in phase 0, and until the ~1 year deletion delay in phase 2 and in the future. From 4baa13050e35e2d3314e7f16ffc48be535bf7530 Mon Sep 17 00:00:00 2001 From: Justin Date: Sat, 16 Feb 2019 21:13:46 +0000 Subject: [PATCH 3/3] Update 0_beacon-chain.md --- specs/core/0_beacon-chain.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/specs/core/0_beacon-chain.md b/specs/core/0_beacon-chain.md index 832b8e523d..3a26c85241 100644 --- a/specs/core/0_beacon-chain.md +++ b/specs/core/0_beacon-chain.md @@ -795,7 +795,7 @@ def get_shuffling(seed: Bytes32, validators: List[Validator], epoch: Epoch) -> List[List[ValidatorIndex]] """ - Shuffle (seeded by ``seed`` and ``epoch``) active validators and split into crosslink committees. + Shuffle active validators and split into crosslink committees. Return a list of committees (each a list of validator indices). """ # Shuffle active validator indices