mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-09 13:28:01 -05:00
37 lines
1.2 KiB
Go
37 lines
1.2 KiB
Go
package sync
|
||
|
||
import (
|
||
"context"
|
||
"errors"
|
||
"fmt"
|
||
|
||
"github.com/OffchainLabs/prysm/v7/config/features"
|
||
ethpb "github.com/OffchainLabs/prysm/v7/proto/prysm/v1alpha1"
|
||
"google.golang.org/protobuf/proto"
|
||
)
|
||
|
||
// beaconAggregateProofSubscriber forwards the incoming validated aggregated attestation and proof to the
|
||
// attestation pool for processing.
|
||
func (s *Service) beaconAggregateProofSubscriber(_ context.Context, msg proto.Message) error {
|
||
a, ok := msg.(ethpb.SignedAggregateAttAndProof)
|
||
if !ok {
|
||
return fmt.Errorf("message was not type ethpb.SignedAggregateAttAndProof, type=%T", msg)
|
||
}
|
||
|
||
aggregate := a.AggregateAttestationAndProof().AggregateVal()
|
||
|
||
if aggregate == nil || aggregate.GetData() == nil {
|
||
return errors.New("nil aggregate")
|
||
}
|
||
|
||
if features.Get().EnableExperimentalAttestationPool {
|
||
return s.cfg.attestationCache.Add(aggregate)
|
||
} else {
|
||
// An unaggregated attestation can make it here. It’s valid, the aggregator it just itself, although it means poor performance for the subnet.
|
||
if !aggregate.IsAggregated() {
|
||
return s.cfg.attPool.SaveUnaggregatedAttestation(aggregate)
|
||
}
|
||
return s.cfg.attPool.SaveAggregatedAttestation(aggregate)
|
||
}
|
||
}
|