mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-25 21:07:18 +00:00
a069738c20
* update shared/params * update eth2-types deps * update protobufs * update shared/* * fix testutil/state * update beacon-chain/state * update beacon-chain/db * update tests * fix test * update beacon-chain/core * update beacon-chain/blockchain * update beacon-chain/cache * beacon-chain/forkchoice * update beacon-chain/operations * update beacon-chain/p2p * update beacon-chain/rpc * update sync/initial-sync * update deps * update deps * go fmt * update beacon-chain/sync * update endtoend/ * bazel build //beacon-chain - works w/o issues * update slasher code * udpate tools/ * update validator/ * update fastssz * fix build * fix test building * update tests * update ethereumapis deps * fix tests * update state/stategen * fix build * fix test * add FarFutureSlot * go imports * Radek's suggestions * Ivan's suggestions * type conversions * Nishant's suggestions * add more tests to rpc_send_request * fix test * clean up * fix conflicts Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com> Co-authored-by: nisdas <nishdas93@gmail.com>
73 lines
2.3 KiB
Go
73 lines
2.3 KiB
Go
package sync
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
"github.com/gogo/protobuf/proto"
|
|
"github.com/pkg/errors"
|
|
types "github.com/prysmaticlabs/eth2-types"
|
|
eth "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
|
|
"github.com/prysmaticlabs/prysm/beacon-chain/cache"
|
|
"github.com/prysmaticlabs/prysm/beacon-chain/core/feed"
|
|
"github.com/prysmaticlabs/prysm/beacon-chain/core/feed/operation"
|
|
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
|
|
"github.com/prysmaticlabs/prysm/shared/params"
|
|
"github.com/prysmaticlabs/prysm/shared/sliceutil"
|
|
)
|
|
|
|
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.attPool.HasAggregatedAttestation(a)
|
|
if err != nil {
|
|
return errors.Wrap(err, "Could not determine if attestation pool has this atttestation")
|
|
}
|
|
if exists {
|
|
return nil
|
|
}
|
|
|
|
// Broadcast the unaggregated attestation on a feed to notify other services in the beacon node
|
|
// of a received unaggregated attestation.
|
|
s.attestationNotifier.OperationFeed().Send(&feed.Event{
|
|
Type: operation.UnaggregatedAttReceived,
|
|
Data: &operation.UnAggregatedAttReceivedData{
|
|
Attestation: a,
|
|
},
|
|
})
|
|
|
|
return s.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)
|
|
}
|