mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-26 13:18:57 +00:00
5aac06f04e
* begin move * use same import path * imports * regen protos * regen * no rename * generate ssz * gaz * fmt * edit build file * imports * modify * remove generated files * remove protos * edit imports in prysm * beacon chain all builds * edit script * add generated pbs * add replace rules * license for ethereumapis protos * change visibility * fmt * update build files to gaz ignore * use proper form * edit imports * wrap block * revert scripts * revert go mod
62 lines
1.9 KiB
Go
62 lines
1.9 KiB
Go
package sync
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
"github.com/pkg/errors"
|
|
types "github.com/prysmaticlabs/eth2-types"
|
|
"github.com/prysmaticlabs/prysm/beacon-chain/cache"
|
|
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
|
|
eth "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1"
|
|
"github.com/prysmaticlabs/prysm/shared/params"
|
|
"github.com/prysmaticlabs/prysm/shared/sliceutil"
|
|
"google.golang.org/protobuf/proto"
|
|
)
|
|
|
|
func (s *Service) committeeIndexBeaconAttestationSubscriber(_ context.Context, msg proto.Message) error {
|
|
a, ok := msg.(*eth.Attestation)
|
|
if !ok {
|
|
return fmt.Errorf("message was not type *eth.Attestation, type=%T", msg)
|
|
}
|
|
|
|
if a.Data == nil {
|
|
return errors.New("nil attestation")
|
|
}
|
|
s.setSeenCommitteeIndicesSlot(a.Data.Slot, a.Data.CommitteeIndex, a.AggregationBits)
|
|
|
|
exists, err := s.cfg.AttPool.HasAggregatedAttestation(a)
|
|
if err != nil {
|
|
return errors.Wrap(err, "Could not determine if attestation pool has this atttestation")
|
|
}
|
|
if exists {
|
|
return nil
|
|
}
|
|
|
|
return s.cfg.AttPool.SaveUnaggregatedAttestation(a)
|
|
}
|
|
|
|
func (s *Service) persistentSubnetIndices() []uint64 {
|
|
return cache.SubnetIDs.GetAllSubnets()
|
|
}
|
|
|
|
func (s *Service) aggregatorSubnetIndices(currentSlot types.Slot) []uint64 {
|
|
endEpoch := helpers.SlotToEpoch(currentSlot) + 1
|
|
endSlot := params.BeaconConfig().SlotsPerEpoch.Mul(uint64(endEpoch))
|
|
var commIds []uint64
|
|
for i := currentSlot; i <= endSlot; i++ {
|
|
commIds = append(commIds, cache.SubnetIDs.GetAggregatorSubnetIDs(i)...)
|
|
}
|
|
return sliceutil.SetUint64(commIds)
|
|
}
|
|
|
|
func (s *Service) attesterSubnetIndices(currentSlot types.Slot) []uint64 {
|
|
endEpoch := helpers.SlotToEpoch(currentSlot) + 1
|
|
endSlot := params.BeaconConfig().SlotsPerEpoch.Mul(uint64(endEpoch))
|
|
var commIds []uint64
|
|
for i := currentSlot; i <= endSlot; i++ {
|
|
commIds = append(commIds, cache.SubnetIDs.GetAttesterSubnetIDs(i)...)
|
|
}
|
|
return sliceutil.SetUint64(commIds)
|
|
}
|