Search in sources :

Example 1 with SignedContributionAndProofTestBuilder

use of tech.pegasys.teku.core.synccomittee.SignedContributionAndProofTestBuilder in project teku by ConsenSys.

the class ChainBuilder method createValidSignedContributionAndProofBuilder.

public SignedContributionAndProofTestBuilder createValidSignedContributionAndProofBuilder(final UInt64 slot, final Bytes32 beaconBlockRoot) {
    final SyncCommitteeUtil syncCommitteeUtil = spec.getSyncCommitteeUtilRequired(slot);
    final SignedBlockAndState latestBlockAndState = getLatestBlockAndState();
    final UInt64 epoch = syncCommitteeUtil.getEpochForDutiesAtSlot(slot);
    final Map<UInt64, SyncSubcommitteeAssignments> subcommitteeAssignments = syncCommitteeUtil.getSyncSubcommittees(latestBlockAndState.getState(), epoch);
    for (Map.Entry<UInt64, SyncSubcommitteeAssignments> entry : subcommitteeAssignments.entrySet()) {
        final UInt64 validatorIndex = entry.getKey();
        final Signer signer = getSigner(validatorIndex.intValue());
        final SyncSubcommitteeAssignments assignments = entry.getValue();
        for (int subcommitteeIndex : assignments.getAssignedSubcommittees()) {
            final SyncAggregatorSelectionData syncAggregatorSelectionData = syncCommitteeUtil.createSyncAggregatorSelectionData(slot, UInt64.valueOf(subcommitteeIndex));
            final BLSSignature proof = signer.signSyncCommitteeSelectionProof(syncAggregatorSelectionData, latestBlockAndState.getState().getForkInfo()).join();
            if (syncCommitteeUtil.isSyncCommitteeAggregator(proof)) {
                return new SignedContributionAndProofTestBuilder().signerProvider(this::getSigner).syncCommitteeUtil(syncCommitteeUtil).spec(spec).state(latestBlockAndState.getState()).subcommitteeIndex(subcommitteeIndex).slot(slot).selectionProof(proof).beaconBlockRoot(beaconBlockRoot).aggregator(validatorIndex, signer);
            }
        }
    }
    throw new IllegalStateException("No valid sync subcommittee aggregators found");
}
Also used : SyncCommitteeUtil(tech.pegasys.teku.spec.logic.common.util.SyncCommitteeUtil) SyncAggregatorSelectionData(tech.pegasys.teku.spec.datastructures.operations.versions.altair.SyncAggregatorSelectionData) Checkpoint(tech.pegasys.teku.spec.datastructures.state.Checkpoint) SignedContributionAndProofTestBuilder(tech.pegasys.teku.core.synccomittee.SignedContributionAndProofTestBuilder) Signer(tech.pegasys.teku.core.signatures.Signer) LocalSigner(tech.pegasys.teku.core.signatures.LocalSigner) SyncSubcommitteeAssignments(tech.pegasys.teku.spec.datastructures.util.SyncSubcommitteeAssignments) SignedBlockAndState(tech.pegasys.teku.spec.datastructures.blocks.SignedBlockAndState) UInt64(tech.pegasys.teku.infrastructure.unsigned.UInt64) Map(java.util.Map) NavigableMap(java.util.NavigableMap) HashMap(java.util.HashMap) TreeMap(java.util.TreeMap) BLSSignature(tech.pegasys.teku.bls.BLSSignature)

Aggregations

HashMap (java.util.HashMap)1 Map (java.util.Map)1 NavigableMap (java.util.NavigableMap)1 TreeMap (java.util.TreeMap)1 BLSSignature (tech.pegasys.teku.bls.BLSSignature)1 LocalSigner (tech.pegasys.teku.core.signatures.LocalSigner)1 Signer (tech.pegasys.teku.core.signatures.Signer)1 SignedContributionAndProofTestBuilder (tech.pegasys.teku.core.synccomittee.SignedContributionAndProofTestBuilder)1 UInt64 (tech.pegasys.teku.infrastructure.unsigned.UInt64)1 SignedBlockAndState (tech.pegasys.teku.spec.datastructures.blocks.SignedBlockAndState)1 SyncAggregatorSelectionData (tech.pegasys.teku.spec.datastructures.operations.versions.altair.SyncAggregatorSelectionData)1 Checkpoint (tech.pegasys.teku.spec.datastructures.state.Checkpoint)1 SyncSubcommitteeAssignments (tech.pegasys.teku.spec.datastructures.util.SyncSubcommitteeAssignments)1 SyncCommitteeUtil (tech.pegasys.teku.spec.logic.common.util.SyncCommitteeUtil)1