From 57e3f8c4653a9ba2f334d59d41de219b7cb86fec Mon Sep 17 00:00:00 2001 From: Age Manning Date: Wed, 3 Oct 2018 15:41:04 +1000 Subject: [PATCH] Correct get_new_shuffling. Closes #25 --- beacon_chain/transition/src/delegation/validator.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/beacon_chain/transition/src/delegation/validator.rs b/beacon_chain/transition/src/delegation/validator.rs index 426b1a5e3..760b6bab7 100644 --- a/beacon_chain/transition/src/delegation/validator.rs +++ b/beacon_chain/transition/src/delegation/validator.rs @@ -1,6 +1,7 @@ use super::types::{ShardAndCommittee, ValidatorRecord, ChainConfig}; use super::TransitionError; use super::shuffle; +use std::cmp::min; type DelegatedSlot = Vec; type DelegatedCycle = Vec; @@ -79,7 +80,9 @@ fn generate_cycle( let (committees_per_slot, slots_per_committee) = { if validator_count >= cycle_length * min_committee_size { - let committees_per_slot = validator_count / cycle_length / (min_committee_size * 2) + 1; + let committees_per_slot = min(validator_count / cycle_length / + (min_committee_size * 2) + 1, shard_count / + cycle_length); let slots_per_committee = 1; (committees_per_slot, slots_per_committee) } else {