# beacon_chain # Copyright (c) 2018-2021 Status Research & Development GmbH # Licensed and distributed under either of # * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT). # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). # at your option. This file may not be copied, modified, or distributed except according to those terms. {.push raises: [Defect].} import std/[intsets], chronicles, ../spec/[ crypto, datatypes, digest, helpers, network, presets, signatures, validator], ../extras, ./block_pools_types, ./blockchain_dag # Spec functions implemented based on cached values instead of the full state func count_active_validators*(epochInfo: EpochRef): uint64 = epochInfo.shuffled_active_validator_indices.lenu64 # https://github.com/ethereum/eth2.0-specs/blob/v1.0.1/specs/phase0/beacon-chain.md#get_committee_count_per_slot func get_committee_count_per_slot*(epochInfo: EpochRef): uint64 = get_committee_count_per_slot(count_active_validators(epochInfo)) iterator get_committee_indices*(epochRef: EpochRef): CommitteeIndex = for i in 0'u64.. 0: yield ( includedIndices, idx, compute_subnet_for_attestation(committees_per_slot, slot, idx), slot)