diff --git a/beacon_chain/spec/datatypes/base.nim b/beacon_chain/spec/datatypes/base.nim index fd204d35c..46786670a 100644 --- a/beacon_chain/spec/datatypes/base.nim +++ b/beacon_chain/spec/datatypes/base.nim @@ -669,12 +669,14 @@ template `[]`*[T](a: seq[T], b: ValidatorIndex): auto = # Also var seq (!) iterator vindices*( a: HashList[Validator, Limit VALIDATOR_REGISTRY_LIMIT]): ValidatorIndex = - for i in 0.. activation_queue[0]: + discard activation_queue.replace val_key ## Dequeued validators for activation up to churn limit (without resetting ## activation epoch) - let churn_limit = get_validator_churn_limit(cfg, state, cache) - for i, epoch_and_index in activation_queue: - if i.uint64 >= churn_limit: - break - let - (_, vidx) = epoch_and_index - state.validators.mitem(vidx).activation_epoch = - compute_activation_exit_epoch(get_current_epoch(state)) + doAssert activation_queue.len.uint64 <= churn_limit + for i in 0 ..< activation_queue.len: + let (_, vidx_complement) = activation_queue[i] + state.validators.mitem( + high(distinctBase(ValidatorIndex)) - vidx_complement).activation_epoch = + compute_activation_exit_epoch(get_current_epoch(state)) ok()