2022-01-20 04:51:02 +00:00
|
|
|
//go:build fuzz
|
2020-09-14 18:42:08 +00:00
|
|
|
|
|
|
|
package sync
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2020-11-19 05:15:58 +00:00
|
|
|
"time"
|
2020-09-14 18:42:08 +00:00
|
|
|
|
|
|
|
pubsub "github.com/libp2p/go-libp2p-pubsub"
|
2022-10-07 07:24:51 +00:00
|
|
|
"github.com/libp2p/go-libp2p/core/peer"
|
2020-11-19 05:15:58 +00:00
|
|
|
gcache "github.com/patrickmn/go-cache"
|
2023-03-17 18:52:56 +00:00
|
|
|
ethpb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1"
|
2021-05-17 18:32:04 +00:00
|
|
|
"google.golang.org/protobuf/proto"
|
2020-09-14 18:42:08 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// NewRegularSyncFuzz service without registering handlers.
|
2021-11-05 19:08:58 +00:00
|
|
|
func NewRegularSyncFuzz(opts ...Option) *Service {
|
2020-09-14 18:42:08 +00:00
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
|
|
r := &Service{
|
2021-11-05 19:08:58 +00:00
|
|
|
cfg: &config{},
|
2020-09-14 18:42:08 +00:00
|
|
|
ctx: ctx,
|
|
|
|
cancel: cancel,
|
2020-11-19 05:15:58 +00:00
|
|
|
slotToPendingBlocks: gcache.New(time.Second, 2*time.Second),
|
2020-09-14 18:42:08 +00:00
|
|
|
seenPendingBlocks: make(map[[32]byte]bool),
|
|
|
|
blkRootToPendingAtts: make(map[[32]byte][]*ethpb.SignedAggregateAttestationAndProof),
|
|
|
|
}
|
2021-11-05 19:08:58 +00:00
|
|
|
r.rateLimiter = newRateLimiter(r.cfg.p2p)
|
2020-09-14 18:42:08 +00:00
|
|
|
|
|
|
|
return r
|
|
|
|
}
|
|
|
|
|
|
|
|
// FuzzValidateBeaconBlockPubSub exports private method validateBeaconBlockPubSub for fuzz testing.
|
|
|
|
func (s *Service) FuzzValidateBeaconBlockPubSub(ctx context.Context, pid peer.ID, msg *pubsub.Message) pubsub.ValidationResult {
|
2021-09-26 01:06:48 +00:00
|
|
|
res, err := s.validateBeaconBlockPubSub(ctx, pid, msg)
|
|
|
|
_ = err
|
|
|
|
return res
|
2020-09-14 18:42:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// FuzzBeaconBlockSubscriber exports private method beaconBlockSubscriber for fuzz testing.
|
|
|
|
func (s *Service) FuzzBeaconBlockSubscriber(ctx context.Context, msg proto.Message) error {
|
|
|
|
return s.beaconBlockSubscriber(ctx, msg)
|
|
|
|
}
|
|
|
|
|
2021-09-02 10:36:54 +00:00
|
|
|
func (s *Service) InitCaches() {
|
|
|
|
s.initCaches()
|
2020-09-14 18:42:08 +00:00
|
|
|
}
|