prysm-pulse/beacon-chain/sync/subscriber_committee_index_beacon_attestation.go
Preston Van Loon 34178aff2a
Strict verify attestations in pubsub (#4782)
* Verify attestations before putting them into the pool
* use existing method
* Validate aggregated ones too
* Revert "Validate aggregated ones too"

This reverts commit a55646d131813c3e65e0539ef5b2e5bda19a5e91.
* Merge branch 'master' of github.com:prysmaticlabs/prysm into verify-all-atts
* Add feature flag
* The remaining shared reference fields with conditional copy on write
* Merge branch 'master' into better-copy-2
* Merge branch 'better-copy-2' of github.com:prysmaticlabs/prysm into verify-all-atts
* gaz
* fix build, put into validate
* lint
* Merge branch 'master' of github.com:prysmaticlabs/prysm into verify-all-atts
* why does goland do this to me
* revert unrelated change
* fix tests
* Update shared/featureconfig/config.go

Co-Authored-By: terence tsao <terence@prysmaticlabs.com>
* Merge refs/heads/master into verify-all-atts
* Update beacon-chain/blockchain/testing/mock.go

Co-Authored-By: terence tsao <terence@prysmaticlabs.com>
* gofmt
2020-02-07 03:21:55 +00:00

32 lines
824 B
Go

package sync
import (
"context"
"fmt"
"github.com/gogo/protobuf/proto"
eth "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
)
func (r *Service) committeeIndexBeaconAttestationSubscriber(ctx 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 exists, _ := r.attPool.HasAggregatedAttestation(a); exists {
return nil
}
return r.attPool.SaveUnaggregatedAttestation(a)
}
func (r *Service) currentCommitteeIndex() int {
activeValidatorIndices, err := r.chain.HeadValidatorsIndices(helpers.SlotToEpoch(r.chain.HeadSlot()))
if err != nil {
panic(err)
}
return int(helpers.SlotCommitteeCount(uint64(len(activeValidatorIndices))))
}