Search in sources :

Example 1 with IntCollection

use of it.unimi.dsi.fastutil.ints.IntCollection in project teku by ConsenSys.

the class ValidatorApiHandler method getAttestationDuties.

@Override
public SafeFuture<Optional<AttesterDuties>> getAttestationDuties(final UInt64 epoch, final IntCollection validatorIndices) {
    if (isSyncActive()) {
        return NodeSyncingException.failedFuture();
    }
    if (epoch.isGreaterThan(combinedChainDataClient.getCurrentEpoch().plus(spec.getSpecConfig(epoch).getMinSeedLookahead() + DUTY_EPOCH_TOLERANCE))) {
        return SafeFuture.failedFuture(new IllegalArgumentException(String.format("Attestation duties were requested %s epochs ahead, only 1 epoch in future is supported.", epoch.minus(combinedChainDataClient.getCurrentEpoch()).toString())));
    }
    final UInt64 slot = spec.getEarliestQueryableSlotForBeaconCommitteeInTargetEpoch(epoch);
    LOG.trace("Retrieving attestation duties from epoch {} using state at slot {}", epoch, slot);
    return combinedChainDataClient.getStateAtSlotExact(slot).thenApply(optionalState -> optionalState.map(state -> getAttesterDutiesFromIndicesAndState(state, epoch, validatorIndices)));
}
Also used : ValidateableSyncCommitteeMessage(tech.pegasys.teku.spec.datastructures.operations.versions.altair.ValidateableSyncCommitteeMessage) BeaconPreparableProposer(tech.pegasys.teku.spec.datastructures.operations.versions.bellatrix.BeaconPreparableProposer) CombinedChainDataClient(tech.pegasys.teku.storage.client.CombinedChainDataClient) SyncCommitteeSubscriptionManager(tech.pegasys.teku.networking.eth2.gossip.subnets.SyncCommitteeSubscriptionManager) BiFunction(java.util.function.BiFunction) GENESIS_SLOT(tech.pegasys.teku.spec.config.SpecConfig.GENESIS_SLOT) BeaconBlock(tech.pegasys.teku.spec.datastructures.blocks.BeaconBlock) AggregatingAttestationPool(tech.pegasys.teku.statetransition.attestation.AggregatingAttestationPool) SignedAggregateAndProof(tech.pegasys.teku.spec.datastructures.operations.SignedAggregateAndProof) BlockImportChannel(tech.pegasys.teku.statetransition.block.BlockImportChannel) AttesterDuties(tech.pegasys.teku.validator.api.AttesterDuties) Collectors.toMap(java.util.stream.Collectors.toMap) SignedBlockAndState(tech.pegasys.teku.spec.datastructures.blocks.SignedBlockAndState) VALIDATOR_LOGGER(tech.pegasys.teku.infrastructure.logging.ValidatorLogger.VALIDATOR_LOGGER) Map(java.util.Map) SyncCommitteeUtil(tech.pegasys.teku.spec.logic.common.util.SyncCommitteeUtil) ValidatorResponse(tech.pegasys.teku.api.response.v1.beacon.ValidatorResponse) Bytes32(org.apache.tuweni.bytes.Bytes32) ChainDataProvider(tech.pegasys.teku.api.ChainDataProvider) GenesisData(tech.pegasys.teku.spec.datastructures.genesis.GenesisData) SyncCommitteeContribution(tech.pegasys.teku.spec.datastructures.operations.versions.altair.SyncCommitteeContribution) IntSets(it.unimi.dsi.fastutil.ints.IntSets) SendSignedBlockResult(tech.pegasys.teku.validator.api.SendSignedBlockResult) BLSSignature(tech.pegasys.teku.bls.BLSSignature) SyncCommitteeDuty(tech.pegasys.teku.validator.api.SyncCommitteeDuty) Collection(java.util.Collection) Set(java.util.Set) StateTransitionException(tech.pegasys.teku.spec.logic.common.statetransition.exceptions.StateTransitionException) List(java.util.List) SyncCommitteeContributionPool(tech.pegasys.teku.statetransition.synccommittee.SyncCommitteeContributionPool) Logger(org.apache.logging.log4j.Logger) ValidatorApiChannel(tech.pegasys.teku.validator.api.ValidatorApiChannel) SyncCommitteeDuties(tech.pegasys.teku.validator.api.SyncCommitteeDuties) ForkChoiceNotifier(tech.pegasys.teku.statetransition.forkchoice.ForkChoiceNotifier) Optional(java.util.Optional) InternalValidationResult(tech.pegasys.teku.statetransition.validation.InternalValidationResult) SubmitDataError(tech.pegasys.teku.validator.api.SubmitDataError) BlockGossipChannel(tech.pegasys.teku.networking.eth2.gossip.BlockGossipChannel) AttestationProcessingResult(tech.pegasys.teku.spec.datastructures.util.AttestationProcessingResult) FailureReason(tech.pegasys.teku.spec.logic.common.statetransition.results.BlockImportResult.FailureReason) SyncCommitteeSubnetSubscription(tech.pegasys.teku.validator.api.SyncCommitteeSubnetSubscription) NodeSyncingException(tech.pegasys.teku.validator.api.NodeSyncingException) ForkChoiceTrigger(tech.pegasys.teku.statetransition.forkchoice.ForkChoiceTrigger) SafeFuture(tech.pegasys.teku.infrastructure.async.SafeFuture) HashMap(java.util.HashMap) AttestationTopicSubscriber(tech.pegasys.teku.networking.eth2.gossip.subnets.AttestationTopicSubscriber) IntCollection(it.unimi.dsi.fastutil.ints.IntCollection) SpecVersion(tech.pegasys.teku.spec.SpecVersion) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) AttestationData(tech.pegasys.teku.spec.datastructures.operations.AttestationData) ValidatorStatus(tech.pegasys.teku.api.response.v1.beacon.ValidatorStatus) SyncCommitteeMessagePool(tech.pegasys.teku.statetransition.synccommittee.SyncCommitteeMessagePool) UInt64(tech.pegasys.teku.infrastructure.unsigned.UInt64) Spec(tech.pegasys.teku.spec.Spec) SignedBeaconBlock(tech.pegasys.teku.spec.datastructures.blocks.SignedBeaconBlock) SubnetSubscription(tech.pegasys.teku.spec.datastructures.validator.SubnetSubscription) LogFormatter.formatBlock(tech.pegasys.teku.infrastructure.logging.LogFormatter.formatBlock) Attestation(tech.pegasys.teku.spec.datastructures.operations.Attestation) CommitteeSubscriptionRequest(tech.pegasys.teku.validator.api.CommitteeSubscriptionRequest) AttestationManager(tech.pegasys.teku.statetransition.attestation.AttestationManager) BLSPublicKey(tech.pegasys.teku.bls.BLSPublicKey) SignedContributionAndProof(tech.pegasys.teku.spec.datastructures.operations.versions.altair.SignedContributionAndProof) PerformanceTracker(tech.pegasys.teku.validator.coordinator.performance.PerformanceTracker) ProposerDuty(tech.pegasys.teku.validator.api.ProposerDuty) Collectors.toList(java.util.stream.Collectors.toList) SyncCommitteeMessage(tech.pegasys.teku.spec.datastructures.operations.versions.altair.SyncCommitteeMessage) AttesterDuty(tech.pegasys.teku.validator.api.AttesterDuty) ValidateableAttestation(tech.pegasys.teku.spec.datastructures.attestation.ValidateableAttestation) SyncStateProvider(tech.pegasys.teku.beacon.sync.events.SyncStateProvider) IntSet(it.unimi.dsi.fastutil.ints.IntSet) VisibleForTesting(com.google.common.annotations.VisibleForTesting) LogManager(org.apache.logging.log4j.LogManager) BeaconState(tech.pegasys.teku.spec.datastructures.state.beaconstate.BeaconState) ProposerDuties(tech.pegasys.teku.validator.api.ProposerDuties) UInt64(tech.pegasys.teku.infrastructure.unsigned.UInt64)

Example 2 with IntCollection

use of it.unimi.dsi.fastutil.ints.IntCollection in project nbt-crafting by Siphalor.

the class MixinRecipeFinder$Filter method method_7422.

/**
 * @reason Builds the idToAmountMap but with calls to ingredient matches
 * @author Siphalor
 */
@Overwrite
private int[] method_7422() {
    owner = NbtCrafting.lastRecipeFinder;
    IntCollection ints = new IntAVLTreeSet();
    for (int id : owner.idToAmountMap.keySet()) {
        for (Ingredient ingredient : ingredients) {
            if (ingredient.test(RecipeFinder.getStackFromId(id)))
                ints.add(id);
        }
    }
    return ints.toIntArray();
}
Also used : Ingredient(net.minecraft.recipe.Ingredient) IntCollection(it.unimi.dsi.fastutil.ints.IntCollection) IntAVLTreeSet(it.unimi.dsi.fastutil.ints.IntAVLTreeSet)

Aggregations

IntCollection (it.unimi.dsi.fastutil.ints.IntCollection)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 IntAVLTreeSet (it.unimi.dsi.fastutil.ints.IntAVLTreeSet)1 IntSet (it.unimi.dsi.fastutil.ints.IntSet)1 IntSets (it.unimi.dsi.fastutil.ints.IntSets)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Set (java.util.Set)1 BiFunction (java.util.function.BiFunction)1 Collectors.toList (java.util.stream.Collectors.toList)1 Collectors.toMap (java.util.stream.Collectors.toMap)1 Ingredient (net.minecraft.recipe.Ingredient)1 LogManager (org.apache.logging.log4j.LogManager)1 Logger (org.apache.logging.log4j.Logger)1 Bytes32 (org.apache.tuweni.bytes.Bytes32)1