diff --git a/beacon-chain/blockchain/process_attestation.go b/beacon-chain/blockchain/process_attestation.go index 47cee31ca0f..bdb1d4a50a4 100644 --- a/beacon-chain/blockchain/process_attestation.go +++ b/beacon-chain/blockchain/process_attestation.go @@ -7,6 +7,7 @@ import ( ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1" "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" stateTrie "github.com/prysmaticlabs/prysm/beacon-chain/state" + "github.com/prysmaticlabs/prysm/shared/attestationutil" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/timeutils" @@ -82,11 +83,18 @@ func (s *Service) onAttestation(ctx context.Context, a *ethpb.Attestation) error return err } - // Use the target state to validate attestation and calculate the committees. - indexedAtt, err := s.verifyAttestationIndices(ctx, baseState, a) + // Use the target state to verify attesting indices are valid. + committee, err := helpers.BeaconCommitteeFromState(baseState, a.Data.Slot, a.Data.CommitteeIndex) if err != nil { return err } + indexedAtt, err := attestationutil.ConvertToIndexed(ctx, a, committee) + if err != nil { + return err + } + if err := attestationutil.IsValidAttestationIndices(ctx, indexedAtt); err != nil { + return err + } // Note that signature verification is ignored here because it was performed in sync's validation pipeline: // validate_aggregate_proof.go and validate_beacon_attestation.go diff --git a/beacon-chain/blockchain/process_attestation_helpers.go b/beacon-chain/blockchain/process_attestation_helpers.go index c2399011d7a..c8efdfc485a 100644 --- a/beacon-chain/blockchain/process_attestation_helpers.go +++ b/beacon-chain/blockchain/process_attestation_helpers.go @@ -10,7 +10,6 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" "github.com/prysmaticlabs/prysm/beacon-chain/core/state" stateTrie "github.com/prysmaticlabs/prysm/beacon-chain/state" - "github.com/prysmaticlabs/prysm/shared/attestationutil" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/mputil" "github.com/prysmaticlabs/prysm/shared/params" @@ -102,19 +101,3 @@ func (s *Service) verifyBeaconBlock(ctx context.Context, data *ethpb.Attestation } return nil } - -// verifyAttestationIndices validates input attestation has valid attesting indices. -func (s *Service) verifyAttestationIndices(ctx context.Context, baseState *stateTrie.BeaconState, a *ethpb.Attestation) (*ethpb.IndexedAttestation, error) { - committee, err := helpers.BeaconCommitteeFromState(baseState, a.Data.Slot, a.Data.CommitteeIndex) - if err != nil { - return nil, err - } - indexedAtt, err := attestationutil.ConvertToIndexed(ctx, a, committee) - if err != nil { - return nil, err - } - if err := attestationutil.IsValidAttestationIndices(ctx, indexedAtt); err != nil { - return nil, err - } - return indexedAtt, nil -}