mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-10 07:58:22 -05:00
Better comments for aggregator functions (#9053)
* Better comments for aggregator functions * Naming returned value
This commit is contained in:
@@ -49,7 +49,7 @@ func (v *validator) SubmitAggregateAndProof(ctx context.Context, slot types.Slot
|
||||
v.aggregatedSlotCommitteeIDCache.Add(k, true)
|
||||
v.aggregatedSlotCommitteeIDCacheLock.Unlock()
|
||||
|
||||
slotSig, err := v.signSlot(ctx, pubKey, slot)
|
||||
slotSig, err := v.signSlotWithSelectionProof(ctx, pubKey, slot)
|
||||
if err != nil {
|
||||
log.Errorf("Could not sign slot: %v", err)
|
||||
if v.emitAccountMetrics {
|
||||
@@ -115,9 +115,8 @@ func (v *validator) SubmitAggregateAndProof(ctx context.Context, slot types.Slot
|
||||
|
||||
}
|
||||
|
||||
// This implements selection logic outlined in:
|
||||
// https://github.com/ethereum/eth2.0-specs/blob/v0.9.3/specs/validator/0_beacon-chain-validator.md#aggregation-selection
|
||||
func (v *validator) signSlot(ctx context.Context, pubKey [48]byte, slot types.Slot) ([]byte, error) {
|
||||
// Signs input slot with domain selection proof. This is used to create the signature for aggregator selection.
|
||||
func (v *validator) signSlotWithSelectionProof(ctx context.Context, pubKey [48]byte, slot types.Slot) (signature []byte, error error) {
|
||||
domain, err := v.domainData(ctx, helpers.SlotToEpoch(slot), params.BeaconConfig().DomainSelectionProof[:])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -546,15 +546,15 @@ func (v *validator) GetKeymanager() keymanager.IKeymanager {
|
||||
return v.keyManager
|
||||
}
|
||||
|
||||
// isAggregator checks if a validator is an aggregator of a given slot, it uses the selection algorithm outlined in:
|
||||
// https://github.com/ethereum/eth2.0-specs/blob/v0.9.3/specs/validator/0_beacon-chain-validator.md#aggregation-selection
|
||||
// isAggregator checks if a validator is an aggregator of a given slot and committee,
|
||||
// it uses a modulo calculated by validator count in committee and samples randomness around it.
|
||||
func (v *validator) isAggregator(ctx context.Context, committee []types.ValidatorIndex, slot types.Slot, pubKey [48]byte) (bool, error) {
|
||||
modulo := uint64(1)
|
||||
if len(committee)/int(params.BeaconConfig().TargetAggregatorsPerCommittee) > 1 {
|
||||
modulo = uint64(len(committee)) / params.BeaconConfig().TargetAggregatorsPerCommittee
|
||||
}
|
||||
|
||||
slotSig, err := v.signSlot(ctx, pubKey, slot)
|
||||
slotSig, err := v.signSlotWithSelectionProof(ctx, pubKey, slot)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user