diff --git a/beacon-chain/p2p/connection_gater.go b/beacon-chain/p2p/connection_gater.go index 477fb4329..896e2b95e 100644 --- a/beacon-chain/p2p/connection_gater.go +++ b/beacon-chain/p2p/connection_gater.go @@ -8,7 +8,6 @@ import ( "github.com/libp2p/go-libp2p-core/network" "github.com/libp2p/go-libp2p-core/peer" "github.com/multiformats/go-multiaddr" - filter "github.com/multiformats/go-multiaddr" manet "github.com/multiformats/go-multiaddr/net" "github.com/sirupsen/logrus" ) @@ -84,15 +83,15 @@ func (s *Service) validateDial(addr multiaddr.Multiaddr) bool { // configureFilter looks at the provided allow lists and // deny lists to appropriately create a filter. -func configureFilter(cfg *Config) (*filter.Filters, error) { - addrFilter := filter.NewFilters() +func configureFilter(cfg *Config) (*multiaddr.Filters, error) { + addrFilter := multiaddr.NewFilters() // Configure from provided allow list in the config. if cfg.AllowListCIDR != "" { _, ipnet, err := net.ParseCIDR(cfg.AllowListCIDR) if err != nil { return nil, err } - addrFilter.AddFilter(*ipnet, filter.ActionAccept) + addrFilter.AddFilter(*ipnet, multiaddr.ActionAccept) } // Configure from provided deny list in the config. if len(cfg.DenyListCIDR) > 0 { @@ -101,7 +100,7 @@ func configureFilter(cfg *Config) (*filter.Filters, error) { if err != nil { return nil, err } - addrFilter.AddFilter(*ipnet, filter.ActionDeny) + addrFilter.AddFilter(*ipnet, multiaddr.ActionDeny) } } return addrFilter, nil @@ -112,8 +111,8 @@ func configureFilter(cfg *Config) (*filter.Filters, error) { // accepts all incoming dials, so if we have an allow list // we will reject all inbound dials except for those in the // appropriate ip subnets. -func filterConnections(f *filter.Filters, a filter.Multiaddr) bool { - acceptedNets := f.FiltersForAction(filter.ActionAccept) +func filterConnections(f *multiaddr.Filters, a multiaddr.Multiaddr) bool { + acceptedNets := f.FiltersForAction(multiaddr.ActionAccept) restrictConns := len(acceptedNets) != 0 // If we have an allow list added in, we by default reject all diff --git a/beacon-chain/p2p/service.go b/beacon-chain/p2p/service.go index f4cd1aaa8..5481cc64d 100644 --- a/beacon-chain/p2p/service.go +++ b/beacon-chain/p2p/service.go @@ -19,22 +19,20 @@ import ( "github.com/libp2p/go-libp2p-core/peer" "github.com/libp2p/go-libp2p-core/protocol" pubsub "github.com/libp2p/go-libp2p-pubsub" - filter "github.com/multiformats/go-multiaddr" - ma "github.com/multiformats/go-multiaddr" + "github.com/multiformats/go-multiaddr" "github.com/pkg/errors" - "github.com/prysmaticlabs/prysm/beacon-chain/p2p/peers/scorers" - "github.com/prysmaticlabs/prysm/shared/featureconfig" - "go.opencensus.io/trace" - "github.com/prysmaticlabs/prysm/beacon-chain/core/feed" statefeed "github.com/prysmaticlabs/prysm/beacon-chain/core/feed/state" "github.com/prysmaticlabs/prysm/beacon-chain/p2p/encoder" "github.com/prysmaticlabs/prysm/beacon-chain/p2p/peers" + "github.com/prysmaticlabs/prysm/beacon-chain/p2p/peers/scorers" pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" "github.com/prysmaticlabs/prysm/shared" + "github.com/prysmaticlabs/prysm/shared/featureconfig" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/runutil" "github.com/prysmaticlabs/prysm/shared/slotutil" + "go.opencensus.io/trace" ) var _ shared.Service = (*Service)(nil) @@ -48,9 +46,6 @@ var pollingPeriod = 6 * time.Second // Refresh rate of ENR set at twice per slot. var refreshRate = slotutil.DivideSlotBy(2) -// lookup limit whenever looking up for random nodes. -const lookupLimit = 15 - // maxBadResponses is the maximum number of bad responses from a peer before we stop talking to it. const maxBadResponses = 5 @@ -66,7 +61,7 @@ type Service struct { cancel context.CancelFunc cfg *Config peers *peers.Status - addrFilter *filter.Filters + addrFilter *multiaddr.Filters ipLimiter *leakybucket.Collector privKey *ecdsa.PrivateKey metaData *pb.MetaData @@ -402,7 +397,7 @@ func (s *Service) awaitStateInitialized() { } } -func (s *Service) connectWithAllPeers(multiAddrs []ma.Multiaddr) { +func (s *Service) connectWithAllPeers(multiAddrs []multiaddr.Multiaddr) { addrInfos, err := peer.AddrInfosFromP2pAddrs(multiAddrs...) if err != nil { log.Errorf("Could not convert to peer address info's from multiaddresses: %v", err) diff --git a/beacon-chain/sync/initial-sync/initial_sync_test.go b/beacon-chain/sync/initial-sync/initial_sync_test.go index cf305aa66..57c7f5418 100644 --- a/beacon-chain/sync/initial-sync/initial_sync_test.go +++ b/beacon-chain/sync/initial-sync/initial_sync_test.go @@ -19,7 +19,6 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/flags" "github.com/prysmaticlabs/prysm/beacon-chain/p2p/peers" p2pt "github.com/prysmaticlabs/prysm/beacon-chain/p2p/testing" - "github.com/prysmaticlabs/prysm/beacon-chain/p2p/types" p2pTypes "github.com/prysmaticlabs/prysm/beacon-chain/p2p/types" beaconsync "github.com/prysmaticlabs/prysm/beacon-chain/sync" p2ppb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" @@ -179,7 +178,7 @@ func connectPeer(t *testing.T, host *p2pt.TestP2P, datum *peerData, peerStatus * if len(sliceutil.IntersectionUint64(datum.failureSlots, requestedBlocks)) > 0 { _, err := stream.Write([]byte{0x01}) assert.NoError(t, err) - msg := types.ErrorMessage("bad") + msg := p2pTypes.ErrorMessage("bad") _, err = p.Encoding().EncodeWithMaxLength(stream, &msg) assert.NoError(t, err) return