@Test public void getBeaconCommittee_stateIsJustNewEnough() { final UInt64 epoch = ONE; final UInt64 epochSlot = compute_start_slot_at_epoch(epoch); final BeaconState state = dataStructureUtil.randomBeaconState(epochSlot); final UInt64 outOfRangeSlot = compute_start_slot_at_epoch(epoch.plus(2)); final UInt64 inRangeSlot = outOfRangeSlot.minus(ONE); assertDoesNotThrow(() -> CommitteeUtil.get_beacon_committee(state, inRangeSlot, ONE)); }
public static List<Integer> get_beacon_committee(BeaconState state, UInt64 slot, UInt64 index) { validateStateForCommitteeQuery(state, slot); return BeaconStateCache.getTransitionCaches(state) .getBeaconCommittee() .get( Pair.of(slot, index), p -> { UInt64 epoch = compute_epoch_at_slot(slot); UInt64 committees_per_slot = get_committee_count_per_slot(state, epoch); int committeeIndex = slot.mod(SLOTS_PER_EPOCH).times(committees_per_slot).plus(index).intValue(); int count = committees_per_slot.times(SLOTS_PER_EPOCH).intValue(); return compute_committee( state, get_active_validator_indices(state, epoch), get_seed(state, epoch, DOMAIN_BEACON_ATTESTER), committeeIndex, count); }); }
CommitteeUtil { public static List<Integer> get_beacon_committee(BeaconState state, UInt64 slot, UInt64 index) { validateStateForCommitteeQuery(state, slot); return BeaconStateCache.getTransitionCaches(state) .getBeaconCommittee() .get( Pair.of(slot, index), p -> { UInt64 epoch = compute_epoch_at_slot(slot); UInt64 committees_per_slot = get_committee_count_per_slot(state, epoch); int committeeIndex = slot.mod(SLOTS_PER_EPOCH).times(committees_per_slot).plus(index).intValue(); int count = committees_per_slot.times(SLOTS_PER_EPOCH).intValue(); return compute_committee( state, get_active_validator_indices(state, epoch), get_seed(state, epoch, DOMAIN_BEACON_ATTESTER), committeeIndex, count); }); } }
CommitteeUtil { public static List<Integer> get_beacon_committee(BeaconState state, UInt64 slot, UInt64 index) { validateStateForCommitteeQuery(state, slot); return BeaconStateCache.getTransitionCaches(state) .getBeaconCommittee() .get( Pair.of(slot, index), p -> { UInt64 epoch = compute_epoch_at_slot(slot); UInt64 committees_per_slot = get_committee_count_per_slot(state, epoch); int committeeIndex = slot.mod(SLOTS_PER_EPOCH).times(committees_per_slot).plus(index).intValue(); int count = committees_per_slot.times(SLOTS_PER_EPOCH).intValue(); return compute_committee( state, get_active_validator_indices(state, epoch), get_seed(state, epoch, DOMAIN_BEACON_ATTESTER), committeeIndex, count); }); }  }
CommitteeUtil { public static List<Integer> get_beacon_committee(BeaconState state, UInt64 slot, UInt64 index) { validateStateForCommitteeQuery(state, slot); return BeaconStateCache.getTransitionCaches(state) .getBeaconCommittee() .get( Pair.of(slot, index), p -> { UInt64 epoch = compute_epoch_at_slot(slot); UInt64 committees_per_slot = get_committee_count_per_slot(state, epoch); int committeeIndex = slot.mod(SLOTS_PER_EPOCH).times(committees_per_slot).plus(index).intValue(); int count = committees_per_slot.times(SLOTS_PER_EPOCH).intValue(); return compute_committee( state, get_active_validator_indices(state, epoch), get_seed(state, epoch, DOMAIN_BEACON_ATTESTER), committeeIndex, count); }); }  static int compute_shuffled_index(int index, int index_count, Bytes32 seed); static void shuffle_list(int[] input, Bytes32 seed); static int compute_proposer_index(BeaconState state, List<Integer> indices, Bytes32 seed); static List<Integer> compute_committee(
      BeaconState state, List<Integer> indices, Bytes32 seed, int index, int count); static List<Integer> get_beacon_committee(BeaconState state, UInt64 slot, UInt64 index); static UInt64 getEarliestQueryableSlotForTargetSlot(final UInt64 slot); static UInt64 getEarliestQueryableSlotForTargetEpoch(final UInt64 epoch); static int getAggregatorModulo(final int committeeSize); static boolean isAggregator(final BLSSignature slot_signature, final int modulo); static int computeSubnetForAttestation(
      final BeaconState state, final Attestation attestation); static int computeSubnetForCommittee(
      final BeaconState state, final UInt64 attestationSlot, final UInt64 committeeIndex); }
CommitteeUtil { public static List<Integer> get_beacon_committee(BeaconState state, UInt64 slot, UInt64 index) { validateStateForCommitteeQuery(state, slot); return BeaconStateCache.getTransitionCaches(state) .getBeaconCommittee() .get( Pair.of(slot, index), p -> { UInt64 epoch = compute_epoch_at_slot(slot); UInt64 committees_per_slot = get_committee_count_per_slot(state, epoch); int committeeIndex = slot.mod(SLOTS_PER_EPOCH).times(committees_per_slot).plus(index).intValue(); int count = committees_per_slot.times(SLOTS_PER_EPOCH).intValue(); return compute_committee( state, get_active_validator_indices(state, epoch), get_seed(state, epoch, DOMAIN_BEACON_ATTESTER), committeeIndex, count); }); }  static int compute_shuffled_index(int index, int index_count, Bytes32 seed); static void shuffle_list(int[] input, Bytes32 seed); static int compute_proposer_index(BeaconState state, List<Integer> indices, Bytes32 seed); static List<Integer> compute_committee(
      BeaconState state, List<Integer> indices, Bytes32 seed, int index, int count); static List<Integer> get_beacon_committee(BeaconState state, UInt64 slot, UInt64 index); static UInt64 getEarliestQueryableSlotForTargetSlot(final UInt64 slot); static UInt64 getEarliestQueryableSlotForTargetEpoch(final UInt64 epoch); static int getAggregatorModulo(final int committeeSize); static boolean isAggregator(final BLSSignature slot_signature, final int modulo); static int computeSubnetForAttestation(
      final BeaconState state, final Attestation attestation); static int computeSubnetForCommittee(
      final BeaconState state, final UInt64 attestationSlot, final UInt64 committeeIndex);  }